diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2956ff25 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,49 @@ +# Generated by: https://openapi-generator.tech +# + +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +## Specific to RubyMotion: +.dat* +.repl_history +build/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + + +/.openapi-generator/ +/spec/ +/.gitlab-ci.yml +/.openapi-generator-ignore +/.travis.yml +/git_push.sh +/test-requirements.txt +/.idea/ diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..d92eff1f --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +VOUCHERIFY_HOST=https://api.voucherify.io +X_APP_ID= +X_APP_TOKEN= diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..e5972592 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '[BUG] ' +labels: bug +assignees: '' + +--- + +**Note** Please remember that this repository is primarily for reporting bugs related to the Ruby SDK. +If you encounter bugs within the product or its documentation, +please consider reporting them to [our support team](https://www.voucherify.io/contact-support) + +**Describe the bug** +A clear and concise description of what the bug is. + +**Steps To Reproduce** +List of steps to reproduce the bug: +1. +2. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..dcc3216f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish SDK + +on: + push: + tags: + - v* + +jobs: + publish: + environment: prod + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + + - name: Install dependencies + run: bundle install + + - name: Build GEM + run: gem build *.gemspec + + - name: Push GEM + run: gem push *.gem --debug + env: + GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..66e99ce0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: Test Workflow + +on: + pull_request: + +jobs: + build-and-test: + runs-on: ubuntu-latest + environment: dev + + steps: + - uses: actions/checkout@v2 + + - name: Build Docker image + run: docker build -t ruby . + + - name: Run tests using Docker + run: | + docker run \ + -e VOUCHERIFY_HOST=${{ vars.VOUCHERIFY_HOST }} \ + -e X_APP_ID=${{ secrets.X_APP_ID }} \ + -e X_APP_TOKEN=${{ secrets.X_APP_TOKEN }} \ + ruby diff --git a/.gitignore b/.gitignore index cd7b08eb..a318c65d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Generated by: https://openapi-generator.tech +# + *.gem *.rbc /.config @@ -28,16 +31,20 @@ build/ # for a library or gem, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock # .ruby-version # .ruby-gemset -Gemfile.lock # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc -# Jetbrains temp -.idea -*.iml -.ruby-version -.vscode/ +/.openapi-generator/ +/spec/ +/.gitlab-ci.yml +/.openapi-generator-ignore +/.travis.yml +/git_push.sh +/test-requirements.txt +/.env +/.idea/ diff --git a/.rspec b/.rspec index 16f9cdb0..83e16f80 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,2 @@ --color ---format documentation +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..d32b2b1c --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,148 @@ +# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license) +# Automatically generated by OpenAPI Generator (https://openapi-generator.tech) +AllCops: + TargetRubyVersion: 2.4 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + Exclude: + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/ElseAlignment: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/FirstArgumentIndentation: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: false + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: indented_internal_methods + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/LeadingCommentSpace: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Style/DefWithParentheses: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: false + EnforcedStyle: always + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +#Style/StringLiterals: +# Enabled: true +# EnforcedStyle: single_quotes + +# Detect hard tabs, no hard tabs. +Layout/IndentationStyle: + Enabled: true + +# Blank lines should not have any spaces. +Layout/TrailingEmptyLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: false + +# Use quotes for string literals when they are enough. +Style/RedundantPercentQ: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + AutoCorrect: true + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +Style/RedundantReturn: + Enabled: true + AllowMultipleReturnValues: true + +Style/Semicolon: + Enabled: true + AllowAsExpressionSeparator: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2a7e7b46..00000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: ruby -rvm: - - 2.7.0 -before_install: - - gem update bundler -install: - - bundle install -script: - - rake spec diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..f18085e3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +- **2022-01-18** - `4.1.0` - Async Actions support. +- **2021-06-14** - `4.0.0` - Bumped required ruby version, bumped dependencies, added `Consents` API support, remove deprecated `URI.escape`. +- **2020-03-09** - `3.0.0` - Bumped required ruby version, bumped dependencies, added `list` method in Customers module. +- **2019-06-19** - `2.4.0` - Added support for custom API endpoint, that allows to connect to projects created in specific Voucherify region. +- **2019-05-09** - `2.3.0` - Added `create_publication` method in Distributions module. +- **2019-04-23** - `2.2.0` - Loyalties API, Rewards API, Orders API. +- **2019-02-19** - `2.1.1` - Treat `referral` as optional in custom events. Added new method for custom event tracking. +- **2019-02-19** - `2.1.0` - Handle `referral` in custom events tracking. +- **2018-12-27** - `2.0.0` - Business validation rules. +- **2018-09-05** - `1.6.1` - Request timeout settings +- **2017-11-16** - `1.6.0` - Expose promotion API, Redemptions and Validations namespace update +- **2017-11-16** - `1.5.0` - Expose events API +- **2017-05-07** - `1.4.0` - Segments, Validation rules, API Versioning +- **2017-03-22** - `1.3.0` - improved error handling +- **2017-01-04** - `1.2.0` - added [import vouchers](#import-vouchers) method. +- **2016-12-29** - `1.1.0` - introduced [campaigns api](#campaigns-api) and [products api](#products-api). +- **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) +- **2016-12-02** - `0.8.2` - support gift vouchers in utils, fix price and discount calculations for amount discounts +- **2016-10-03** - `0.8.1` - publish update +- **2016-08-02** - `0.8.0` - validate voucher +- **2016-07-18** - `0.7.0` - voucher udpate +- **2016-07-05** - `0.6.0` - new utils module +- **2016-06-16** - `0.5.0` - unified naming convention +- **2016-06-12** - `0.4.0` - new customer sdk methods +- **2016-05-24** - `0.3.0` - new publish structure +- **2016-04-27** - `0.2.0` - rollback redemption +- **2016-04-13** - `0.1.3` - bugfix in redeem() +- **2016-04-13** - `0.1.2` - removed dependency to `pry` +- **2016-04-12** - `0.1.1` - minor gemspec changes +- **2016-04-12** - `0.1.0` - First version: + - Authentication + - Voucher information: *retrieve voucher*, *list vouchers*, *retrieve redemptions*, *list redemptions* + - Voucher operations: *redeem voucher*, *publish voucher*, *create voucher*, *enable/disable voucher* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bf5d779b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ruby:3.3 + +WORKDIR /app + +COPY . . + +RUN gem build VoucherifySdk.gemspec +RUN gem install voucherify-5.0.0.gem +RUN gem install dotenv +RUN gem install rspec + +WORKDIR /app/__tests__ + +CMD ["rspec", "./spec"] diff --git a/ENDPOINTS-COVERAGE.md b/ENDPOINTS-COVERAGE.md new file mode 100644 index 00000000..ce8cbd9d --- /dev/null +++ b/ENDPOINTS-COVERAGE.md @@ -0,0 +1,868 @@ +# Endpoints Coverage +# Table of Contents + +- [Publications](#publications) + - [/v1/publications/create](#v1publicationscreate) + - [/v1/publications](#v1publications) +- [Qualifications](#qualifications) + - [/v1/qualifications](#v1qualifications) +- [Validations](#validations) + - [/v1/validations](#v1validations) + - [/v1/vouchers/{code}/validate](#v1voucherscodevalidate-deprecated) + - [/v1/promotions/validation](#v1promotionsvalidation-deprecated) + - [/v1/promotions/tiers/{tierId}/validation](#v1promotionstierstieridvalidation-deprecated) +- [Redemptions](#redemptions) + - [/v1/redemptions](#v1redemptions) + - [/v1/redemptions/{redemptionId}](#v1redemptionsredemptionid) + - [/v1/vouchers/{code}/redemption](#v1voucherscoderedemption) + - [/v1/redemptions/{redemptionId}/rollback](#v1redemptionsredemptionidrollback) + - [/v1/promotions/tiers/{promotionTierId}/redemption](#v1promotionstierspromotiontieridredemption-deprecated) + - [/v1/redemptions/{parentRedemptionId}/rollbacks](#v1redemptionsparentredemptionidrollbacks) +- [Vouchers](#vouchers) + - [/v1/vouchers](#v1vouchers) + - [/v1/vouchers/{code}](#v1voucherscode) + - [/v1/vouchers/{code}/enable](#v1voucherscodeenable) + - [/v1/vouchers/{code}/disable](#v1voucherscodedisable) + - [/v1/vouchers/{code}/balance](#v1voucherscodebalance) + - [/v1/vouchers/{code}/transactions](#v1voucherscodetransactions) + - [/v1/vouchers/{code}/transactions/export](#v1voucherscodetransactionsexport) + - [/v1/vouchers/import](#v1vouchersimport) + - [/v1/vouchers/importCSV](#v1vouchersimportcsv) + - [/v1/vouchers/bulk/async](#v1vouchersbulkasync) + - [/v1/vouchers/metadata/async](#v1vouchersmetadataasync) + - [/v1/vouchers/{code}/sessions/{sessionKey}](#v1voucherscodesessionssessionkey) + - [/v1/vouchers/qualification](#v1vouchersqualification-deprecated) +- [Campaigns](#campaigns) + - [/v1/campaigns](#v1campaigns) + - [/v1/campaigns/{campaignId}](#v1campaignscampaignid) + - [/v1/campaigns/{campaignId}/vouchers](#v1campaignscampaignidvouchers) + - [/v1/campaigns/{campaignId}/vouchers/{code}](#v1campaignscampaignidvoucherscode) + - [/v1/campaigns/{campaignId}/import](#v1campaignscampaignidimport) + - [/v1/campaigns/{campaignId}/importCSV](#v1campaignscampaignidimportcsv) + - [/v1/campaigns/qualification](#v1campaignsqualification-deprecated) + - [/v1/campaigns/{campaignId}/enable](#v1campaignscampaignidenable) + - [/v1/campaigns/{campaignId}/disable](#v1campaignscampaigniddisable) +- [Promotions](#promotions) + - [/v1/promotions/tiers](#v1promotionstiers) + - [/v1/promotions/{campaignId}/tiers](#v1promotionscampaignidtiers) + - [/v1/promotions/tiers/{promotionTierId}](#v1promotionstierspromotiontierid) + - [/v1/promotions/tiers/{promotionTierId}/enable](#v1promotionstierspromotiontieridenable) + - [/v1/promotions/tiers/{promotionTierId}/disable](#v1promotionstierspromotiontieriddisable) + - [/v1/promotions/stacks](#v1promotionsstacks) + - [/v1/promotions/{campaignId}/stacks](#v1promotionscampaignidstacks) + - [/v1/promotions/{campaignId}/stacks/{stackId}](#v1promotionscampaignidstacksstackid) +- [Rewards](#rewards) + - [/v1/rewards](#v1rewards) + - [/v1/rewards/{rewardId}](#v1rewardsrewardid) + - [/v1/rewards/{rewardId}/assignments](#v1rewardsrewardidassignments) + - [/v1/rewards/{rewardId}/assignments/{assignmentId}](#v1rewardsrewardidassignmentsassignmentid) +- [Loyalties](#loyalties) + - [/v1/loyalties](#v1loyalties) + - [/v1/loyalties/{campaignId}](#v1loyaltiescampaignid) + - [/v1/loyalties/{campaignId}/members](#v1loyaltiescampaignidmembers) + - [/v1/loyalties/{campaignId}/members/{memberId}](#v1loyaltiescampaignidmembersmemberid) + - [/v1/loyalties/members/{memberId}](#v1loyaltiesmembersmemberid) + - [/v1/loyalties/{campaignId}/members/{memberId}/activities](#v1loyaltiescampaignidmembersmemberidactivities) + - [/v1/loyalties/members/{memberId}/activities](#v1loyaltiesmembersmemberidactivities) + - [/v1/loyalties/{campaignId}/members/{memberId}/balance](#v1loyaltiescampaignidmembersmemberidbalance) + - [/v1/loyalties/members/{memberId}/balance](#v1loyaltiesmembersmemberidbalance) + - [/v1/loyalties/{campaignId}/members/{memberId}/transfers](#v1loyaltiescampaignidmembersmemberidtransfers) + - [/v1/loyalties/{campaignId}/members/{memberId}/transactions](#v1loyaltiescampaignidmembersmemberidtransactions) + - [/v1/loyalties/members/{memberId}/transactions](#v1loyaltiesmembersmemberidtransactions) + - [/v1/loyalties/members/{memberId}/transactions/export](#v1loyaltiesmembersmemberidtransactionsexport) + - [/v1/loyalties/{campaignId}/members/{memberId}/transactions/export](#v1loyaltiescampaignidmembersmemberidtransactionsexport) + - [/v1/loyalties/{campaignId}/members/{memberId}/points-expiration](#v1loyaltiescampaignidmembersmemberidpoints-expiration) + - [/v1/loyalties/{campaignId}/points-expiration/export](#v1loyaltiescampaignidpoints-expirationexport) + - [/v1/loyalties/{campaignId}/earning-rules](#v1loyaltiescampaignidearning-rules) + - [/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}](#v1loyaltiescampaignidearning-rulesearningruleid) + - [/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/enable](#v1loyaltiescampaignidearning-rulesearningruleidenable) + - [/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/disable](#v1loyaltiescampaignidearning-rulesearningruleiddisable) + - [/v1/loyalties/members/{memberId}/rewards](#v1loyaltiesmembersmemberidrewards) + - [/v1/loyalties/{campaignId}/reward-assignments/{assignmentId}/reward](#v1loyaltiescampaignidreward-assignmentsassignmentidreward) + - [/v1/loyalties/{campaignId}/reward-assignments](#v1loyaltiescampaignidreward-assignments) + - [/v1/loyalties/{campaignId}/rewards](#v1loyaltiescampaignidrewards) + - [/v1/loyalties/{campaignId}/reward-assignments/{assignmentId}](#v1loyaltiescampaignidreward-assignmentsassignmentid) + - [/v1/loyalties/{campaignId}/rewards/{assignmentId}](#v1loyaltiescampaignidrewardsassignmentid) + - [/v1/loyalties/{campaignId}/members/{memberId}/redemption](#v1loyaltiescampaignidmembersmemberidredemption) + - [/v1/loyalties/members/{memberId}/redemption](#v1loyaltiesmembersmemberidredemption) + - [/v1/loyalties/{campaignId}/tiers](#v1loyaltiescampaignidtiers) + - [/v1/loyalties/{campaignId}/tiers/{loyaltyTierId}](#v1loyaltiescampaignidtiersloyaltytierid) + - [/v1/loyalties/members/{memberId}/tiers](#v1loyaltiesmembersmemberidtiers) + - [/v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/earning-rules](#v1loyaltiescampaignidtiersloyaltytieridearning-rules) + - [/v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/rewards](#v1loyaltiescampaignidtiersloyaltytieridrewards) +- [Customers](#customers) + - [/v1/customers](#v1customers) + - [/v1/customers/{customerId}](#v1customerscustomerid) + - [/v1/customers/{customerId}/permanent-deletion](#v1customerscustomeridpermanent-deletion) + - [/v1/customers/importCSV](#v1customersimportcsv) + - [/v1/customers/bulk/async](#v1customersbulkasync) + - [/v1/customers/metadata/async](#v1customersmetadataasync) + - [/v1/customers/{customerId}/consents](#v1customerscustomeridconsents) + - [/v1/customers/{customerId}/activities](#v1customerscustomeridactivities) + - [/v1/customers/{customerId}/segments](#v1customerscustomeridsegments) +- [Orders](#orders) + - [/v1/orders](#v1orders) + - [/v1/orders/{orderId}](#v1ordersorderid) + - [/v1/orders/import](#v1ordersimport) + - [/v1/orders/export](#v1ordersexport) +- [Products](#products) + - [/v1/products](#v1products) + - [/v1/products/{productId}](#v1productsproductid) + - [/v1/products/bulk/async](#v1productsbulkasync) + - [/v1/products/metadata/async](#v1productsmetadataasync) + - [/v1/skus/{skuId}](#v1skusskuid) + - [/v1/products/{productId}/skus](#v1productsproductidskus) + - [/v1/products/{productId}/skus/{skuId}](#v1productsproductidskusskuid) + - [/v1/products/importCSV](#v1productsimportcsv) + - [/v1/skus/importCSV](#v1skusimportcsv) +- [Product Collections](#product collections) + - [/v1/product-collections](#v1product-collections) + - [/v1/product-collections/{productCollectionId}](#v1product-collectionsproductcollectionid) + - [/v1/product-collections/{productCollectionId}/products](#v1product-collectionsproductcollectionidproducts) +- [Validation Rules](#validation rules) + - [/v1/validation-rules](#v1validation-rules) + - [/v1/validation-rules/{validationRuleId}](#v1validation-rulesvalidationruleid) + - [/v1/validation-rules-assignments](#v1validation-rules-assignments) + - [/v1/validation-rules/{validationRuleId}/assignments](#v1validation-rulesvalidationruleidassignments) + - [/v1/validation-rules/{validationRuleId}/assignments/{assignmentId}](#v1validation-rulesvalidationruleidassignmentsassignmentid) +- [Segments](#segments) + - [/v1/segments/{segmentId}](#v1segmentssegmentid) + - [/v1/segments](#v1segments) +- [Events](#events) + - [/v1/events](#v1events) +- [Consents](#consents) + - [/v1/consents](#v1consents) +- [Async Actions](#async actions) + - [/v1/async-actions](#v1async-actions) + - [/v1/async-actions/{asyncActionId}](#v1async-actionsasyncactionid) +- [Exports](#exports) + - [/v1/exports](#v1exports) + - [/v1/exports/{exportId}](#v1exportsexportid) + - [/v1/exports/{export_Id}](#v1exportsexport_id) +- [Categories](#categories) + - [/v1/categories](#v1categories) + - [/v1/categories/{categoryId}](#v1categoriescategoryid) +- [Metadata Schemas](#metadata schemas) + - [/v1/metadata-schemas](#v1metadata-schemas) + - [/v1/metadata-schemas/{resource}](#v1metadata-schemasresource) +- [Locations](#locations) + - [/v1/locations](#v1locations) + - [/v1/locations/{locationId}](#v1locationslocationid) +- [Client-side](#client-side) + - [/client/v1/qualifications](#clientv1qualifications) + - [/client/v1/promotions/tiers](#clientv1promotionstiers) + - [/client/v1/redemptions](#clientv1redemptions) + - [/client/v1/validations](#clientv1validations) + - [/client/v1/customers/{customerId}/consents](#clientv1customerscustomeridconsents) + - [/client/v1/events](#clientv1events) + - [/client/v1/consents](#clientv1consents) + - [/client/v1/validate](#clientv1validate-deprecated) + - [/client/v1/redeem](#clientv1redeem-deprecated) +# Endpoints + +## Publications +### /v1/publications/create +#### Create Publication (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/publications +#### List Publications (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/publications_list_response_body.rb) ✅ +#### Create Publication (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/publications_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/publications_create_response_body.rb) ✅ +## Qualifications +### /v1/qualifications +#### Check Eligibility (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/qualifications_check_eligibility_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/qualifications_check_eligibility_response_body.rb) ✅ +## Validations +### /v1/validations +#### Validate Stackable Discounts (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/validations_validate_response_body.rb) ✅ +- **ResponseSupported:** ❌ +### ~~❗/v1/vouchers/{code}/validate [Deprecated]❗~~ +#### ~~❗Validate Voucher [Deprecated] (post)❗~~ +### ~~❗/v1/promotions/validation [Deprecated]❗~~ +#### ~~❗Validate Promotions [Deprecated] (post)❗~~ +### ~~❗/v1/promotions/tiers/{tierId}/validation [Deprecated]❗~~ +#### ~~❗Validate Promotion Tier [Deprecated] (post)❗~~ +## Redemptions +### /v1/redemptions +#### List Redemptions (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/redemptions_list_response_body.rb) ✅ +#### Redeem Stackable Discounts (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/redemptions_redeem_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/redemptions_redeem_response_body.rb) ✅ +### /v1/redemptions/{redemptionId} +#### Get Redemption (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/redemptions_get_response_body.rb) ✅ +### /v1/vouchers/{code}/redemption +#### Get Voucher's Redemptions (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_redemption_get_response_body.rb) ✅ +#### ~~❗Redeem Voucher [Deprecated] (post)❗~~ +### /v1/redemptions/{redemptionId}/rollback +#### Rollback Redemption (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/redemptions_rollback_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/redemptions_rollback_create_response_body.rb) ✅ +### ~~❗/v1/promotions/tiers/{promotionTierId}/redemption [Deprecated]❗~~ +#### ~~❗Redeem Promotion [Deprecated] (post)❗~~ +### /v1/redemptions/{parentRedemptionId}/rollbacks +#### Rollback Stackable Redemptions (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/redemptions_rollbacks_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/redemptions_rollbacks_create_response_body.rb) ✅ +## Vouchers +### /v1/vouchers +#### List Vouchers (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Generate Random Code (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/vouchers/{code} +#### Get Voucher (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_get_response_body.rb) ✅ +#### Update Voucher (put) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +#### Delete Voucher (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +#### Create Voucher (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/vouchers/{code}/enable +#### Enable Voucher (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_enable_response_body.rb) ✅ +### /v1/vouchers/{code}/disable +#### Disable Voucher (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_disable_response_body.rb) ✅ +### /v1/vouchers/{code}/balance +#### Add or Remove Voucher Balance (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/vouchers_balance_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_balance_update_response_body.rb) ✅ +### /v1/vouchers/{code}/transactions +#### List Voucher Transactions (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_transactions_list_response_body.rb) ✅ +### /v1/vouchers/{code}/transactions/export +#### Export Voucher Transactions (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/vouchers_transactions_export_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_transactions_export_create_response_body.rb) ✅ +### /v1/vouchers/import +#### Import Vouchers (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/vouchers/importCSV +#### Import Vouchers using CSV (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/vouchers_import_csv_create_response_body.rb) ✅ +### /v1/vouchers/bulk/async +#### Update Vouchers in bulk (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/vouchers/metadata/async +#### Update Vouchers' metadata in bulk (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/vouchers/{code}/sessions/{sessionKey} +#### Release Validation Session (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### ~~❗/v1/vouchers/qualification [Deprecated]❗~~ +#### ~~❗Examine Qualification [Deprecated] (post)❗~~ +## Campaigns +### /v1/campaigns +#### Create Campaign (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/campaigns_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_create_response_body.rb) ✅ +#### List Campaigns (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_list_response_body.rb) ✅ +### /v1/campaigns/{campaignId} +#### Get Campaign (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_get_response_body.rb) ✅ +#### Update Campaign (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/campaigns_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_update_response_body.rb) ✅ +#### Delete Campaign (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_delete_response_body.rb) ✅ +### /v1/campaigns/{campaignId}/vouchers +#### Add Vouchers to Campaign (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/campaigns_vouchers_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_vouchers_create_response_body.rb) ✅ +### /v1/campaigns/{campaignId}/vouchers/{code} +#### Add Voucher with Specific Code to Campaign (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/campaigns_vouchers_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_vouchers_create_response_body.rb) ✅ +### /v1/campaigns/{campaignId}/import +#### Import Vouchers to Campaign (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/campaigns_import_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_import_create_response_body.rb) ✅ +### /v1/campaigns/{campaignId}/importCSV +#### Import Vouchers to Campaign by CSV (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_import_csv_create_response_body.rb) ✅ +### ~~❗/v1/campaigns/qualification [Deprecated]❗~~ +#### ~~❗Examine Qualification [Deprecated] (post)❗~~ +### /v1/campaigns/{campaignId}/enable +#### Enable Campaign (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_enable_response_body.rb) ✅ +### /v1/campaigns/{campaignId}/disable +#### Disable Campaign (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/campaigns_disable_response_body.rb) ✅ +## Promotions +### /v1/promotions/tiers +#### List Promotion Tiers (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/promotions/{campaignId}/tiers +#### List Promotion Tiers from Campaign (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_tiers_list_response_body.rb) ✅ +#### Add Promotion Tier to Campaign (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/promotions/tiers/{promotionTierId} +#### Get Promotion Tier (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_tiers_get_response_body.rb) ✅ +#### Update Promotion Tier (put) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +#### Delete Promotion Tier (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/promotions/tiers/{promotionTierId}/enable +#### Enable Promotion Tier (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_tiers_enable_response_body.rb) ✅ +### /v1/promotions/tiers/{promotionTierId}/disable +#### Disable Promotion Tier (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_tiers_disable_response_body.rb) ✅ +### /v1/promotions/stacks +#### List Promotion Stacks (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_stacks_list_response_body.rb) ✅ +### /v1/promotions/{campaignId}/stacks +#### List Promotion Stacks in Campaign (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_stacks_list_response_body.rb) ✅ +#### Create Promotion Stack (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/promotions_stacks_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_stacks_create_response_body.rb) ✅ +### /v1/promotions/{campaignId}/stacks/{stackId} +#### Get Promotion Stack (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_stacks_get_response_body.rb) ✅ +#### Update Promotion Stack (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/promotions_stacks_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/promotions_stacks_update_response_body.rb) ✅ +#### Delete Promotion Stack (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +## Rewards +### /v1/rewards +#### List Rewards (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Create Reward (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/rewards/{rewardId} +#### Get Reward (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Update Reward (put) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +#### Delete Reward (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/rewards/{rewardId}/assignments +#### List Reward Assignments (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/rewards_assignments_list_response_body.rb) ✅ +#### Create Reward Assignment (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/rewards_assignments_create_response_body.rb) ✅ +- **ResponseSupported:** ❌ +### /v1/rewards/{rewardId}/assignments/{assignmentId} +#### Update Reward Assignment (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/rewards_assignments_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/rewards_assignments_update_response_body.rb) ✅ +#### Delete Reward Assignment (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +#### Get Reward Assignment (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/rewards_assignments_get_response_body.rb) ✅ +## Loyalties +### /v1/loyalties +#### List Loyalty Campaigns (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Create Loyalty Campaign (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/loyalties/{campaignId} +#### Get Loyalty Campaign (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Update Loyalty Campaign (put) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +#### Delete Loyalty Campaign (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_delete_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/members +#### List Members (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Add Member (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/loyalties/{campaignId}/members/{memberId} +#### Get Member (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/loyalties/members/{memberId} +#### Get Member (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/loyalties/{campaignId}/members/{memberId}/activities +#### Get Member Activities (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/loyalties/members/{memberId}/activities +#### Get Member Activities (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/loyalties/{campaignId}/members/{memberId}/balance +#### Add or Remove Loyalty Card Balance (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_balance_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_balance_update_response_body.rb) ✅ +### /v1/loyalties/members/{memberId}/balance +#### Add or Remove Loyalty Card Balance (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_balance_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_balance_update_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/members/{memberId}/transfers +#### Transfer Loyalty Points (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transfers_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transfers_create_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/members/{memberId}/transactions +#### List Loyalty Card Transactions (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transactions_list_response_body.rb) ✅ +### /v1/loyalties/members/{memberId}/transactions +#### List Loyalty Card Transactions (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transactions_list_response_body.rb) ✅ +### /v1/loyalties/members/{memberId}/transactions/export +#### Export Loyalty Card Transactions (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transactions_export_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transactions_export_create_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/members/{memberId}/transactions/export +#### Export Loyalty Card Transactions (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transactions_export_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_transactions_export_create_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/members/{memberId}/points-expiration +#### Get Points Expiration (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_points_expiration_list_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/points-expiration/export +#### Create Points Expiration Export (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/loyalties/{campaignId}/earning-rules +#### List Earning Rules (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Create Earning Rule (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** *Not applicable* +### /v1/loyalties/{campaignId}/earning-rules/{earningRuleId} +#### Get Earning Rule (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_earning_rules_get_response_body.rb) ✅ +#### Update Earning Rule (put) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +#### Delete Earning Rule (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/enable +#### Enable Earning Rule (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_earning_rules_enable_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/disable +#### Disable Earning Rule (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_earning_rules_disable_response_body.rb) ✅ +### /v1/loyalties/members/{memberId}/rewards +#### List Member Rewards (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_rewards_list_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/reward-assignments/{assignmentId}/reward +#### Get Reward Details (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_reward_assignments_reward_get_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/reward-assignments +#### List Reward Assignments (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/loyalties/{campaignId}/rewards +#### List Reward Assignments (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Create Reward Assignment (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/loyalties/{campaignId}/reward-assignments/{assignmentId} +#### Get Reward Assignment (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_reward_assignments_get_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/rewards/{assignmentId} +#### Get Reward Assignment (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_rewards_get_response_body.rb) ✅ +#### Update Reward Assignment (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/4_obj_reward_assignment_object.rb) ✅ +- **ResponseSupported:** ❌ +#### Delete Reward Assignment (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/loyalties/{campaignId}/members/{memberId}/redemption +#### Redeem Reward (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_redemption_redeem_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_redemption_redeem_response_body.rb) ✅ +### /v1/loyalties/members/{memberId}/redemption +#### Redeem Reward (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_redemption_redeem_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_redemption_redeem_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/tiers +#### List Loyalty Tiers (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_tiers_list_response_body.rb) ✅ +#### Create loyalty tiers (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/loyalties_tiers_create_in_bulk_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_tiers_create_in_bulk_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/tiers/{loyaltyTierId} +#### Get Loyalty Tier (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_tiers_get_response_body.rb) ✅ +### /v1/loyalties/members/{memberId}/tiers +#### List Member's Loyalty Tiers (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_members_tiers_list_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/earning-rules +#### List Loyalty Tier Earning Rules (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_tiers_earning_rules_list_response_body.rb) ✅ +### /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/rewards +#### List Loyalty Tier Rewards (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/loyalties_tiers_rewards_list_response_body.rb) ✅ +## Customers +### /v1/customers +#### List Customers (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_list_response_body.rb) ✅ +#### Create Customer (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/customers_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_create_response_body.rb) ✅ +### /v1/customers/{customerId} +#### Get Customer (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_get_response_body.rb) ✅ +#### Delete Customer (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +#### Update Customer (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/customers_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_update_response_body.rb) ✅ +### /v1/customers/{customerId}/permanent-deletion +#### Delete Customer Permanently (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_permanent_deletion_create_response_body.rb) ✅ +### /v1/customers/importCSV +#### Import and Update Customers using CSV (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_import_csv_create_response_body.rb) ✅ +### /v1/customers/bulk/async +#### Update Customers in bulk (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_update_in_bulk_response_body.rb) ✅ +### /v1/customers/metadata/async +#### Update Customers' Metadata in bulk (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/customers_metadata_update_in_bulk_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_metadata_update_in_bulk_response_body.rb) ✅ +### /v1/customers/{customerId}/consents +#### Update Customer's consents (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/.rb) ✅ +- **ResponseSupported:** *Not applicable* +### /v1/customers/{customerId}/activities +#### List Customer Activities (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_activities_list_response_body.rb) ✅ +### /v1/customers/{customerId}/segments +#### List Customer's Segments (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/customers_segments_list_response_body.rb) ✅ +## Orders +### /v1/orders +#### List Orders (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/orders_list_response_body.rb) ✅ +#### Create Order (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/orders_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/orders_create_response_body.rb) ✅ +### /v1/orders/{orderId} +#### Get Order (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/orders_get_response_body.rb) ✅ +#### Update Order (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/orders_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/orders_update_response_body.rb) ✅ +### /v1/orders/import +#### Import Orders (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/orders_import_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/orders_import_create_response_body.rb) ✅ +### /v1/orders/export +#### Create Orders Export (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/orders_export_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/orders_export_create_response_body.rb) ✅ +## Products +### /v1/products +#### List Products (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_list_response_body.rb) ✅ +#### Create Product (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/products_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_create_response_body.rb) ✅ +### /v1/products/{productId} +#### Get Product (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_get_response_body.rb) ✅ +#### Update Product (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/products_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_update_response_body.rb) ✅ +#### Delete Product (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/products/bulk/async +#### Update Products in bulk (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_update_in_bulk_response_body.rb) ✅ +### /v1/products/metadata/async +#### Update Products' Metadata in bulk (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/products_metadata_update_in_bulk_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_metadata_update_in_bulk_response_body.rb) ✅ +### /v1/skus/{skuId} +#### Get SKU (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/skus_get_response_body.rb) ✅ +### /v1/products/{productId}/skus +#### List SKUs in Product (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_skus_list_response_body.rb) ✅ +#### Create SKU (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/products_skus_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_skus_create_response_body.rb) ✅ +### /v1/products/{productId}/skus/{skuId} +#### Update SKU (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/products_skus_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_skus_update_response_body.rb) ✅ +#### Delete SKU (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/products/importCSV +#### Import Products using CSV (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/products_import_csv_create_response_body.rb) ✅ +### /v1/skus/importCSV +#### Import SKUs using CSV (post) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/skus_import_csv_create_response_body.rb) ✅ +## Product Collections +### /v1/product-collections +#### List Product Collections (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/product_collections_list_response_body.rb) ✅ +#### Create Product Collection (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/product_collections_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/product_collections_create_response_body.rb) ✅ +### /v1/product-collections/{productCollectionId} +#### Get Product Collection (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/product_collections_get_response_body.rb) ✅ +#### Delete Product Collection (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/product-collections/{productCollectionId}/products +#### List Products in Collection (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/product_collections_products_list_response_body.rb) ✅ +## Validation Rules +### /v1/validation-rules +#### List Validation Rules (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/validation_rules_list_response_body.rb) ✅ +#### Create Validation Rules (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/validation_rules_create_response_body.rb) ✅ +- **ResponseSupported:** ❌ +### /v1/validation-rules/{validationRuleId} +#### Get Validation Rule (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/validation_rules_get_response_body.rb) ✅ +#### Update Validation Rule (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/validation_rules_update_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/validation_rules_update_response_body.rb) ✅ +#### Delete Validation Rule (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/validation-rules-assignments +#### List Validation Rules' Assignment(s) (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/validation_rules_assignments_list_response_body.rb) ✅ +### /v1/validation-rules/{validationRuleId}/assignments +#### List Validation Rule Assignments (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/validation_rules_assignments_list_response_body.rb) ✅ +#### Create Validation Rules Assignments (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +### /v1/validation-rules/{validationRuleId}/assignments/{assignmentId} +#### Delete Validation Rule Assignment (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +## Segments +### /v1/segments/{segmentId} +#### Get Segment (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +#### Delete Segment (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/segments +#### Create Segment (post) +- **RequestSupported:** ❌ +- **ResponseSupported:** ❌ +## Events +### /v1/events +#### Track Custom Event (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/events_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/events_create_response_body.rb) ✅ +## Consents +### /v1/consents +#### List Consents (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +## Async Actions +### /v1/async-actions +#### List Async Actions (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/async-actions/{asyncActionId} +#### Get Async Action (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +## Exports +### /v1/exports +#### Create Export (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/exports_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/exports_create_response_body.rb) ✅ +#### List Exports (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/exports_list_response_body.rb) ✅ +### /v1/exports/{exportId} +#### Get Export (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/exports_get_response_body.rb) ✅ +#### Delete Export (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +### /v1/exports/{export_Id} +#### Download Export (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +## Categories +### /v1/categories +#### List Categories (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/categories_list_response_body.rb) ✅ +#### Create Category (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/categories_create_response_body.rb) ✅ +- **ResponseSupported:** ❌ +### /v1/categories/{categoryId} +#### Get Category (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/categories_get_response_body.rb) ✅ +#### Delete Category (delete) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** *Not applicable* +#### Update Category (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/categories_update_response_body.rb) ✅ +- **ResponseSupported:** ❌ +## Metadata Schemas +### /v1/metadata-schemas +#### List Metadata Schemas (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/metadata-schemas/{resource} +#### Get Metadata Schema (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +## Locations +### /v1/locations +#### List Locations (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /v1/locations/{locationId} +#### Get Location (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +## Client-side +### /client/v1/qualifications +#### Check Eligibility (client-side) (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/client_qualifications_check_eligibility_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/client_qualifications_check_eligibility_response_body.rb) ✅ +### /client/v1/promotions/tiers +#### List Promotion Tiers (client-side) (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### /client/v1/redemptions +#### Redeem Stackable Discounts (client-side) (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/client_redemptions_redeem_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/client_redemptions_redeem_response_body.rb) ✅ +### /client/v1/validations +#### Validate Stackable Discounts (client-side) (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/client_validations_validate_response_body.rb) ✅ +- **ResponseSupported:** ❌ +### /client/v1/customers/{customerId}/consents +#### Update Customer's consents (client-side) (put) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/.rb) ✅ +- **ResponseSupported:** *Not applicable* +### /client/v1/events +#### Track Custom Event (client-side) (post) +- **RequestSupported:** [link](./lib/VoucherifySDK/models/client_events_create_response_body.rb) ✅ +- **ResponseSupported:** [link](./lib/VoucherifySDK/models/client_events_create_response_body.rb) ✅ +### /client/v1/consents +#### List Consents (client-side) (get) +- **RequestSupported:** *Not applicable* +- **ResponseSupported:** ❌ +### ~~❗/client/v1/validate [Deprecated]❗~~ +#### ~~❗Validate Voucher (client-side) [Deprecated] (get)❗~~ +### ~~❗/client/v1/redeem [Deprecated]❗~~ +#### ~~❗Redeem Voucher (client-side) [Deprecated] (post)❗~~ diff --git a/EXAMPLES.md b/EXAMPLES.md new file mode 100644 index 00000000..e5943882 --- /dev/null +++ b/EXAMPLES.md @@ -0,0 +1,112 @@ +# How to Manage Code Efficiently + +There are two possible ways to define a model. +You can use the standard class-based initialization, where you create a new object for each nesting level. + +```ruby +campaign = campaigns_api_instance.create_campaign({ + campaigns_create_request_body: VoucherifySdk::CampaignsCreateDiscountCouponsCampaign.new({ + campaign_type: "DISCOUNT_COUPONS", + name: generate_random_string(), + type: "AUTO_UPDATE", + voucher: VoucherifySdk::DiscountCouponsCampaignVoucher.new({ + discount: VoucherifySdk::DiscountAmount.new({ + type: "AMOUNT", + amount_off: 1000 + }) + }), + validation_rules: [validation_rule_id] + }) +}) +``` + +Another, simpler approach is to create only **necessary** objects. In this scenario, the model is created using JSON-like syntax.. + +```ruby +campaign = campaigns_api_instance.create_campaign({ + campaigns_create_request_body: VoucherifySdk::CampaignsCreateDiscountCouponsCampaign.new({ + campaign_type: "DISCOUNT_COUPONS", + name: generate_random_string(), + type: "AUTO_UPDATE", + voucher: { + discount: { + type: "AMOUNT", + amount_off: 1000 + } + }, + validation_rules: [validation_rule_id] + }) +}) +``` + +Some objects are **necessary** because they represent a union of a few similar types, and you need to determine which type you're using. + +E.g. model [**CampaignsCreateRequestBody**](./lib/VoucherifySdk/models/campaigns_create_request_body.rb) consists of types like: +- CampaignsCreateDiscountCouponsCampaign +- CampaignsCreateGiftCampaign +- CampaignsCreateGiveawayCampaign +- CampaignsCreateLoyaltyCampaign +- CampaignsCreatePromotionCampaign +- CampaignsCreateReferralCampaign + +So, in our example, we're declaring an object for it, instead of passing it explicitly. For example: +```ruby +campaigns_create_request_body: VoucherifySdk::CampaignsCreateDiscountCouponsCampaign.new(...) +``` + +##### 💡 More useful examples could be found in our [tests](./__tests__) + +## 🔄 Alternative ways for installing a gem + +To build the Ruby code into a gem: + +```shell +gem build VoucherifySdk.gemspec +``` + +Then either install the gem locally: + +```shell +gem install ./VoucherifySdk-1.0.0.gem +``` + +(for development, run `gem install --dev ./VoucherifySdk-1.0.0.gem` to install the development dependencies) + +Add this to the Gemfile: + +```shell +gem 'VoucherifySdk', '~> 1.0.0' +``` + +Then install dependencies with bundler + +```shell +bundle install +``` + +Finally, exec script with bundler: + +```shell +bundle exec ruby example.rb +``` + +### 📦 Install from Git + +You could use the GitHub repository (https://github.com/voucherifyio/voucherify-js-sdk) for installing SDK gem by adding it to the `Gemfile` + +```shell +gem 'VoucherifySdk', :git => 'https://github.com/voucherifyio/voucherify-js-sdk.git', branch: 'main' +``` + +Then install dependencies with bundler + +```shell +bundle install +``` + +Finally, exec script with bundler: + +```shell +bundle exec ruby example.rb +``` + diff --git a/Gemfile b/Gemfile index dc879f7c..c2e3127c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,9 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in voucherify.gemspec gemspec + +group :development, :test do + gem 'rake', '~> 13.0.1' + gem 'pry-byebug' + gem 'rubocop', '~> 0.66.0' +end diff --git a/LICENSE b/LICENSE index dc51aed2..83bb84bb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2016 rspective P.Rychlik sp.j. +Copyright (c) 2024 voucherify.io Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 8ae72db7..b9d09439 100644 --- a/README.md +++ b/README.md @@ -1,925 +1,949 @@ -# This repository is no longer actively maintained, we have a new SDK for Ruby at [voucherifyio/sdk-ruby-openapi-based](https://github.com/voucherifyio/sdk-ruby-openapi-based). - -

- -

- -

Official Voucherify SDK for Ruby

- -

- - Build Status - Gem Version - Gem Downloads -

-
- -

-Migration from 0.x -| -Setup -| -Error handling -| -Development -| -Contributing -| -Changelog -

- -

-API: -Vouchers -| -Campaigns -| -Distributions -| -Validations -| -Redemptions -| -Customers -| -Products -| -Validation Rules -| -Segments -| -Promotions -| -Events -| -Orders -| -Loyalties -| -Rewards -| -Utils -

- ---- - -## Setup - -### Voucherify gem starting from 3.x requires ruby version >= 2.2 - -Add this line to your application's Gemfile: +![Voucherify Ruby SDK](./voucherify-ruby-sdk.png) -```ruby -gem 'voucherify' -``` - -And then execute: - - $ bundle +## Official [Voucherify](https://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq) SDK for Ruby -Or install it yourself as: +[![Gem Version](https://img.shields.io/gem/v/voucherify.svg)](https://rubygems.org/gems/voucherify) +[![Gem Downloads](https://img.shields.io/gem/dt/voucherify.svg)](https://rubygems.org/gems/voucherify) +[![License](https://img.shields.io/github/license/voucherifyio/sdk-ruby-openapi-based.svg)](https://opensource.org/licenses/MIT) +[![GitHub issues](https://img.shields.io/github/issues/voucherifyio/sdk-ruby-openapi-based.svg)](https://github.com/voucherifyio/sdk-ruby-openapi-based/issues) - $ gem install voucherify +Voucherify empowers marketers and developers with flexible building blocks to come up with, implement, and track targeted promotional campaigns. -[Log-in](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/login) to Voucherify web interface and obtain your Application Keys from [Configuration](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/app/configuration): +Learn more about Voucherify by visiting [our site](https://www.voucherify.io). -```ruby -require 'voucherify' - -voucherify = Voucherify::Client.new({ - :applicationId => 'YOUR-APPLICATION-ID', - :clientSecretKey => 'YOUR-CLIENT-SECRET-KEY' -}) -``` - -You can also specify which API version you want to use: -```ruby -voucherify = Voucherify::Client.new({ - :applicationId => 'YOUR-APPLICATION-ID', - :clientSecretKey => 'YOUR-CLIENT-SECRET-KEY', - :apiVersion => 'v2017-04-05' -}) -``` - -and timeout settings: -```ruby -voucherify = Voucherify::Client.new({ - :applicationId => 'YOUR-APPLICATION-ID', - :clientSecretKey => 'YOUR-CLIENT-SECRET-KEY', - :apiVersion => 'v2017-04-05', - :timeout => 10 // in seconds -}) -``` +This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) based on our [Documentation](https://docs.voucherify.io/docs/introduction) with v2018-08-01 version. -### API Endpoint +The legacy version of Ruby SDK could be found [here](https://github.com/voucherifyio/voucherify-ruby-sdk) -Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region. +## 📝 Documentation -```ruby -voucherify = Voucherify::Client.new({ - :applicationId => 'YOUR-APPLICATION-ID', - :clientSecretKey => 'YOUR-CLIENT-SECRET-KEY', - :apiUrl => 'https://.api.voucherify.io' -}) -``` +You will find detailed description and example responses at our [official documentation](https://docs.voucherify.io/reference). Most method headers point to more detailed descriptions of arguments you can use. -## API - -This SDK is fully consistent with restful API Voucherify provides. -Detailed descriptions and example responses you will find at [official docs](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq). -Method headers point to more detailed params description you can use. - -### Vouchers API -Methods are provided within `voucherify.vouchers.*` namespace. -- [Create Voucher](#create-voucher) -- [Get Voucher](#get-voucher) -- [Update Voucher](#update-voucher) -- [Delete Voucher](#delete-voucher) -- [List Vouchers](#list-vouchers) -- [Enable Voucher](#enable-voucher) -- [Disable Voucher](#disable-voucher) -- [Import Vouchers](#import-vouchers) -- [Add Gift Voucher Balance](#add-gift-voucher-balance) - -#### [Create Voucher] -```ruby -voucherify.vouchers.create(code, options) -``` -Check [voucher object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-voucher-object). -#### [Get Voucher] -```ruby -voucherify.vouchers.get(code) -``` -#### [Update Voucher] -```ruby -voucherify.vouchers.update(voucher) -``` -#### [Delete Voucher] -```ruby -voucherify.vouchers.delete(code, [params]) -``` -#### [List Vouchers] -```ruby -voucherify.vouchers.list -``` -#### [Enable Voucher] -```ruby -voucherify.vouchers.enable(code) -``` -#### [Disable Voucher] -```ruby -voucherify.vouchers.disable(code) -``` -#### [Import Vouchers] -```ruby -voucherify.vouchers.import(vouchers) -``` -#### [Add Gift Voucher Balance] -```ruby -voucherify.vouchers().add_balance(code, balance); -``` +📚 Want to learn more? Visit our [official site](https://www.voucherify.io) or our [Success Portal](https://success.voucherify.io). ---- +👽 Having troubles? Check our [Help center](https://support.voucherify.io/). -### Campaigns API -Methods are provided within `voucherify.campaigns.*` namespace. -- [Create Campaign](#create-campaign) -- [Get Campaign](#get-campaign) -- [Add Voucher to Campaign](#add-voucher-to-campaign) -- [Import Vouchers to Campaign](#import-vouchers-to-campaign) +🧪 Looking for promotion ideas? Check our [Cookbook](https://cookbook.voucherify.io/) to get an inspiration. -#### [Create Campaign] -```ruby -voucherify.campaigns.create(campaign) -``` -#### [Get Campaign] -```ruby -voucherify.campaigns.get(campaign_name) -``` -#### [Add Voucher to Campaign] -```ruby -voucherify.campaigns.add_voucher(campaign_name, [params]) -``` -#### [Import Vouchers to Campaign] -```ruby -voucherify.campaigns.import_vouchers(campaign_name, vouchers) -``` +🐛 Encounter a bug? Please file a report in the [Issues](https://github.com/voucherifyio/sdk-ruby-openapi-based/issues). ---- +## ⚙️ Installation -### Distributions API -Methods are provided within `voucherify.distributions.*` namespace. +### Gem Repository -- [Publish Vouchers](#publish-vouchers) -- [Create Export](#create-export) -- [Get Export](#get-export) -- [Delete Export](#delete-export) -- [List Publications](#list-publications) -- [Create Publication](#create-publication) +The SDK is hosted in [RubeGems](https://rubygems.org/gems/voucherify) and could be easy obtained by adding this line to Your application's Gemfile: -#### [Publish Vouchers] -```ruby -voucherify.distributions.publish(campaign_name) -``` -#### [Create Export] -```ruby -voucherify.distributions.create_export(export) -``` -#### [Get Export] -```ruby -voucherify.distributions.get_export(export_id) -``` -#### [Delete Export] -```ruby -voucherify.distributions.delete_export(export_id) -``` -#### [List Publications] ```ruby -voucherify.distributions.list_publications(params) -``` -#### [Create Publication] -```ruby -voucherify.distributions.create_publication(publication) +gem 'voucherify' ``` ---- - -### Validations API -Methods are provided within `voucherify.validations.*` namespace. - -- [Validate Voucher](#validate-voucher) -- [Validate Promotion Campaign](#validate-promotion-campaign) - -#### [Validate Voucher] -```ruby -voucherify.validations.validate_voucher(code, [context]) - -# or -voucherify.validations.validate(code, [context]) -``` +And then execute: -#### [Validate Promotion Campaign] -```ruby -voucherify.validations.validate(promo_validation_context) +```shell +bundle install ``` ---- - -### Redemptions API -Methods are provided within `voucherify.redemptions.*` namespace. - -- [Redeem Voucher](#redeem-voucher) -- [List Redemptions](#list-redemptions) -- [Get Voucher's Redemptions](#get-vouchers-redemptions) -- [Get Redemption](#get-redemption) -- [Rollback Redemption](#rollback-redemption) - -#### [Redeem Voucher] -```ruby -# Redeem voucher code -voucherify.redemptions.redeem(code, [params]) - -# Redeem promotion campaign -voucherify.redemptions.redeem(promotions_tier, [params]) +Or install it yourself as: -# Removed! -voucherify.redemptions.redeem(code, tracking_id) # use: voucherify.redemptions.redeem(code, {:customer => {:source_id => 'source_id'}}) -``` -#### [List Redemptions] -```ruby -voucherify.redemptions.list -voucherify.redemptions.list(params) -``` -#### [Get Voucher's Redemptions] -```ruby -voucherify.redemptions.get_for_voucher(code) -``` -#### [Get Redemption] -```ruby -voucherify.redemptions.get(redemption_id); +```shell +gem install voucherify ``` -#### [Rollback Redemption] -```ruby -voucherify.redemptions.rollback(redemption_id, [params]) -# Removed! -voucherify.redemptions.rollback(code, tracking_id, reason) # use: voucherify.redemptions.rollback(code, {:customer => {:source_id => 'source_id'}, :reason => 'reason'}) -``` -Check [redemption rollback object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-redemption-rollback-object). +### 🚀 Running code ---- +When You have Voucherify gem installed You could use pre-created [example.rb](./example.rb) with example code for testing purpose. -### Promotions API -Methods are provided within `voucherify.promotions.*` namespace. +```ruby example.rb +# Load the gem +require 'VoucherifySdk' -- [Create Promotion Campaign](#create-promotion-campaign) -- [Validate Promotion Campaign](#validate-promotion-campaign) -- [List Promotion's Tiers](#list-promotions-tiers) -- [Create Promotion's Tier](#create-promotions-tier) -- [Redeem Promotion's Tier](#redeem-promotions-tier) -- [Update Promotion's Tier](#update-promotions-tier) -- [Delete Promotion's Tier](#delete-promotions-tier) +# Setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-App-Id + config.api_key['X-App-Id'] = 'YOUR API KEY' -Check [promotion campaign object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-promotion-campaign). -#### [Create Promotion Campaign] -```ruby -voucherify.promotions.create(promotion_campaign) -``` -#### [Validate Promotion Campaign] -```ruby -voucherify.promotions.validate(validation_context) -``` -#### [List Promotion's Tiers] -```ruby -voucherify.promotions.tiers.list(promotion_campaign_id) -``` -Check [promotion's tier object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-promotion-object) -#### [Create Promotion's Tier] -```ruby -voucherify.promotions.tiers.create(promotion_id, promotions_tier) -``` -#### [Redeem Promotion's Tier] -```ruby -voucherify.promotions.tiers.redeem(promotions_tier_id, redemption_context) -``` -#### [Update Promotion's Tier] -```ruby -voucherify.promotions.tiers.update(promotions_tier) -``` -#### [Delete Promotion's Tier] -```ruby -voucherify.promotions.tiers.delete(promotions_tier_id) -``` - ---- - -### Customers API -Methods are provided within `voucherify.customers.*` namespace. - -- [List Customers](#list-customers) -- [Create Customer](#create-customer) -- [Get Customer](#get-customer) -- [Update Customer](#update-customer) -- [Delete Customer](#delete-customer) + # Configure API key authorization: X-App-Token + config.api_key['X-App-Token'] = 'YOUR API KEY' -#### [List Customers] -```ruby -voucherify.customers.list(options) -``` -Check [options](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-customers). + # (Optional) Configure Voucherify cluster, default is https://api.voucherify.io + # config.host = 'https://us1.api.voucherify.io' +end -#### [Create Customer] -```ruby -voucherify.customers.create(customer) -``` -Check [customer object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-customer-object). -#### [Get Customer] -```ruby -voucherify.customers.get(customer_id) -``` -#### [Update Customer] -```ruby -voucherify.customers.update(customer) -``` -#### [Delete Customer] -```ruby -voucherify.customers.delete(customer_id) -``` +# Creating API Instance +api_instance = VoucherifySdk::CampaignsApi.new -### Products API -Methods are provided within `voucherify.products.*` namespace. - -- [Create Product](#create-product) -- [Get Product](#get-product) -- [Update Product](#update-product) -- [Delete Product](#delete-product) -- [List Products](#list-products) -- [Create SKU](#create-sku) -- [Get SKU](#get-sku) -- [Update SKU](#update-sku) -- [Delete SKU](#delete-sku) -- [List all product SKUs](#list-all-product-skus) - -#### [Create Product] -```ruby -voucherify.products.create(product) -``` -Check [product object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-product-object). -#### [Get Product] -```ruby -voucherify.products.get(product_id) -``` -#### [Update Product] -```ruby -voucherify.products.update(product) -``` -#### [Delete Product] -```ruby -voucherify.products.delete(product_id) -``` -#### [List Products] -```ruby -voucherify.products.list([params]) -``` -#### [Create SKU] -```ruby -voucherify.products.create_sku(product_id, sku) -``` -Check [SKU object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-sku-object). -#### [Get SKU] -```ruby -voucherify.products.get_sku(product_id, sku_id) -``` -#### [Update SKU] -```ruby -voucherify.products.update_sku(product_id, sku) -``` -#### [Delete SKU] -```ruby -voucherify.products.delete_sku(product_id, sku_id) -``` -#### [List all product SKUs] -```ruby -voucherify.products.list_skus(product_id) +# Calling list_campaigns +begin + result = api_instance.list_campaigns() + puts result +rescue VoucherifySdk::ApiError => e + puts "Exception when calling VouchersApi->list_campaigns: #{e}" +end ``` ---- - -### Validation Rules API -Methods are provided within `voucherify.validation_rules.*` namespace. - -- [Create Validation Rules](#create-validation-rules) -- [Get Validation Rules](#get-validation-rules) -- [List Validation Rules](#list-validation-rules) -- [Update Validation Rules](#update-validation-rules) -- [Delete Validation Rules](#delete-validation-rules) - -- [Create Validation Rule Assignment](#create-validation-rule-assignment) -- [List Validation Rule Assignments](#list-validation-rule-assignments) -- [Delete Validation Rule Assignment](#delete-validation-rule-assignment) - -#### [Create Validation Rules] -```ruby -voucherify.validation_rules.create(rules); -``` -#### [Get Validation Rules] -```ruby -voucherify.validation_rules.get(id); -``` -#### [List Validation Rules] -```ruby -voucherify.validation_rules.list(query); -``` -#### [Update Validation Rules] -```ruby -voucherify.validation_rules.update(rules); -``` -#### [Delete Validation Rules] -```ruby -voucherify.validation_rules.delete(id); -``` +Code could be run from the directory where the file is placed (root for this repository), by using: -#### [Create Validation Rule Assignment] -```ruby -voucherify.validation_rules.assignments.create(rule_id, assignment); +```shell +ruby example.rb ``` -#### [List Validation Rule Assignments] -```ruby -voucherify.validation_rules.assignments.list(rule_id, query); -``` -#### [Delete Validation Rule Assignment] -```ruby -voucherify.validation_rules.assignments.delete(rule_id, assignment_id); -``` ---- - -### Segments API -Methods are provided within `voucherify.segments.*` namespace. -- [Create Segment](#create-segment) -- [Get Segment](#get-segment) -- [Delete Validation Rules](#delete-segment) +Or, if You're using bundler: -#### [Create Segment] -```ruby -voucherify.segments.create(segment); -``` -#### [Get Segment] -```ruby -voucherify.segments.get(id); -``` -#### [Delete Segment] -```ruby -voucherify.segments.delete(id); +```shell +bundle exec ruby example.rb ``` ---- +🛡️ This code does simple campaign list, so it won't affect Your Voucherify data. -### Orders API +🔒 Remember to fill Your Voucherify keys for the valid authorization. -#### [Create Order] -```ruby -voucherify.orders.create(order); -``` -#### [Get Order] -```ruby -voucherify.orders.get(id); -``` -#### [Update Order] -```ruby -voucherify.orders.update(id, order); -``` -#### [List orders] -```ruby -voucherify.orders.list(params); -``` +💅 More examples and good practices You could find in the [EXAMPLES.md](./EXAMPLES.md) document. ---- +## 🐳 Running local tests with docker -### Rewards API - -#### [Create Rewards] -```ruby -voucherify.rewards.create(reward); -``` -#### [Get Reward] -```ruby -voucherify.rewards.get(id); -``` -#### [Update Reward] -```ruby -voucherify.rewards.update(id, reward); -``` -#### [List Rewards] -```ruby -voucherify.rewards.list(params); -``` -#### [Delete Reward] -```ruby -voucherify.rewards.delete(id); -``` - -#### [List Reward Assignments] -```ruby -voucherify.rewards.assignments.list(reward_id, query); -``` -#### [Create Reward Assignment] -```ruby -voucherify.rewards.assignments.create(reward_id, assignment); -``` -#### [Update Reward Assignment] -```ruby -voucherify.rewards.assignments.update(reward_id, assignment_id, assignment); -``` -#### [Delete Reward Assignment] -```ruby -voucherify.rewards.assignments.delete(reward_id, assignment_id); -``` ---- +1. Copy `.env.example` to `.env` and fill in the values. +2. Run `docker build -t ruby .` to build the image. +3. Run `docker run --rm ruby` to run the tests and delete container immediately after. -### Loyalties API +## 🛠️ Contributing -#### [List Loyalties] -```ruby -voucherify.loyalties.list(query); -``` -#### [Create Loyalty] -```ruby -voucherify.loyalties.create(loyalty); -``` -#### [Get Loyalty] -```ruby -voucherify.loyalties.get(id); -``` -#### [Update Loyalty] -```ruby -voucherify.loyalties.update(id, loyalty); -``` -#### [Delete Loyalty] -```ruby -voucherify.loyalties.delete(id); -``` +Read more about how to Contribute to Voucherify Ruby SDK by visiting main repo [GENERATING-SDKS.md](https://github.com/voucherifyio/voucherify-openapi/blob/master/GENERATING-SDKS.md) -#### [List Loyalty Reward Assignments] -```ruby -voucherify.loyalties.assignments.list(loyalty_id, query); -``` -#### [Create Loyalty Reward Assignment] -```ruby -voucherify.loyalties.assignments.create(loyalty_id, assignment); -``` -#### [Update Loyalty Reward Assignment] -```ruby -voucherify.loyalties.assignments.update(loyalty_id, assignment_id, assignment); -``` -#### [Delete Loyalty Reward Assignment] -```ruby -voucherify.loyalties.assignments.delete(loyalty_id, assignment_id); -``` +Remember that this SDK is auto generated (except of the tests) so changes made here will be overwritten by generator. -#### [List Loyalty Earning Rules] -```ruby -voucherify.loyalties.earning_rules.list(loyalty_id, query); -``` -#### [Create Loyalty Earning Rule] -```ruby -voucherify.loyalties.earning_rules.create(loyalty_id, earning_rule); -``` -#### [Update Loyalty Earning Rule] -```ruby -voucherify.loyalties.earning_rules.update(loyalty_id, earning_rule_id, earning_rule); -``` -#### [Delete Loyalty Earning Rule] -```ruby -voucherify.loyalties.earning_rules.delete(loyalty_id, earning_rule_id); -``` +## Changelog -#### [List Loyalty Members] -```ruby -voucherify.loyalties.members.list(loyalty_id, query); -``` -#### [Add Loyalty Member] -```ruby -voucherify.loyalties.members.add(loyalty_id, member); -``` -#### [Get Loyalty Member] -```ruby -voucherify.loyalties.members.get(loyalty_id, member_id); -``` -#### [Add Loyalty Card Balance] -```ruby -voucherify.loyalties.members.add_balance(loyalty_id, member_id, add_balance); -``` -#### [Redeem Loyalty Reward] -```ruby -voucherify.loyalties.members.redeem_reward(loyalty_id, member_id, redeem_reward); -``` ---- +- **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. -### Events API -Methods are provided within `voucherify.events.*` namespace. +*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).* -- [Events](#events) +*Changelog for previous versions could be found in the [CHANGELOG.md file](./CHANGELOG.md)* -#### [Create event] -```ruby -voucherify.events.track(event, metadata, customer, referral); -``` +## 🔐 Documentation for Authorization ```ruby -voucherify.events.track_event(data); -``` - -### Async Actions API -Methods are provided within `voucherify.async_actions.*` namespace. -- [Get Async Action](#get-async-action) -- [List Async Actions](#list-async-actions) +# Setup authorization +VoucherifySdk.configure do |config| + # Application Keys + config.api_key['X-App-Id'] = 'YOUR API ID' + config.api_key['X-App-Token'] = 'YOUR API TOKEN' -#### [Get Async Action] -```java -voucherify.async_actions.get(id); -``` - -#### [List Async Actions] -```java -voucherify.async_actions.list(query); -``` + # Client-side Keys + config.api_key['X-Client-Application-Id'] = 'YOUR CLIENT API ID' + config.api_key['X-Client-Token'] = 'YOUR CLIENT API TOKEN' ---- - -### Migration from 0.x - -Version 1.x of the SDK is not backwards compatible with versions 0.x. -Changes made in version 1.x mostly relate to grouping methods within namespaces. -So all you need to do is to follow the list bellow and just replace methods -with their namespaced equivalent. - -- `Voucherify.new(params)` - `Voucherify::Client.new(params)` -- `voucherify.create(voucher)` - [voucherify.vouchers.create](#create-voucher) -- `voucherify.get(voucher_code)` - [voucherify.vouchers.get](#get-voucher) -- `voucherify.update(voucher)` - [voucherify.vouchers.update](#update-voucher) -- `voucherify.list(params)` - [voucherify.vouchers.list](#list-vouchers) -- `voucherify.enable(voucher_code)` - [voucherify.vouchers.enable](#enable-voucher) -- `voucherify.disable(voucher_code)` - [voucherify.vouchers.disable](#disable-voucher) -- `voucherify.publish(campaign_name)` - [voucherify.distributions.publish](#publish-vouchers) -- `voucherify.validate(voucher_code, params)` - [voucherify.validations.validate](#validate-voucher) -- `voucherify.redeem(voucher_code, tracking_id)` - [voucherify.redemptions.redeem](#redeem-voucher) -- `voucherify.redemption(voucher_code)` - [voucherify.redemptions.get_for_voucher](#get-vouchers-redemptions) -- `voucherify.redemptions(params)` - [voucherify.redemptions.list](#list-redemptions) -- `voucherify.rollback(redemption_id, tracking_id, reason)` - [voucherify.redemptions.rollback](#rollback-redemptions) -- `voucherify.create_customer(customer)` - [voucherify.customers.create](#create-customer) -- `voucherify.get_customer(customer_id)` - [voucherify.customers.get](#get-customer) -- `voucherify.update_customer(customer)` - [voucherify.customers.update](#update-customer) -- `voucherify.delete_customer(customer_id)` - [voucherify.customers.delete](#delete-customer) -- `Utils.round_money(value)` - `Voucherify::Utils.round_money(value)` -- `Utils.validate_percent_discount(discount)` - `Voucherify::Utils.validate_percent_discount(discount)` -- `Utils.validate_amount_discount(discount)` - `Voucherify::Utils.validate_amount_discount(discount)` -- `Utils.validate_unit_discount(discount)` - `Voucherify::Utils.validate_unit_discount(discount)` -- `Utils.calculate_price(base_price, voucher, [unit_price])` - `Voucherify::Utils.calculate_price(base_price, voucher, [unit_price])` -- `Utils.calculate_discount(base_price, voucher, [unit_price])` - `Voucherify::Utils.calculate_discount(base_price, voucher, [unit_price])` - ---- - -### Utils - -#### Available methods - -- `Voucherify::Utils.round_money(value)` -- `Voucherify::Utils.validate_percent_discount(discount)` -- `Voucherify::Utils.validate_amount_discount(discount)` -- `Voucherify::Utils.validate_unit_discount(discount)` -- `Voucherify::Utils.calculate_price(base_price, voucher, [unit_price])` -- `Voucherify::Utils.calculate_discount(base_price, voucher, [unit_price])` - ---- - -## Error handling - -When the Voucherify API responds with an error (HTTP status code is 4xx or 5xx) then the client raises a `VoucherifyError`. -It contains following properties: -- `code` - HTTP status code -- `message` - a human-readable message providing short description about the error. -- `details` - a human-readable message providing more details about the error, usually includes a hint on how to fix the error -- `key` - a short string describing the kind of error that occurred. - -Example: - -```ruby -begin - voucherify.distributions.publish('test') -rescue Voucherify::VoucherifyError => e - puts e.code - puts e.message - puts e.details - puts e.key + # Cluster (Optional) + # default is https://api.voucherify.io + config.host = 'https://us1.api.voucherify.io' end ``` -The ouput may be: - -``` -400 -Couldn't find any voucher suitable for publication. -Use auto-update campaigns if you want Voucherify to generate vouchers automatically. -no_voucher_suitable_for_publication -``` - -## Development - -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. - -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). - -## Contributing - -Bug reports and pull requests are welcome on GitHub at https://github.com/rspective/voucherify-ruby-sdk. - -## Changelog -- **2022-01-18** - `4.1.0` - Async Actions support. -- **2021-06-14** - `4.0.0` - Bumped required ruby version, bumped dependencies, added `Consents` API support, remove deprecated `URI.escape`. -- **2020-03-09** - `3.0.0` - Bumped required ruby version, bumped dependencies, added `list` method in Customers module. -- **2019-06-19** - `2.4.0` - Added support for custom API endpoint, that allows to connect to projects created in specific Voucherify region. -- **2019-05-09** - `2.3.0` - Added `create_publication` method in Distributions module. -- **2019-04-23** - `2.2.0` - Loyalties API, Rewards API, Orders API. -- **2019-02-19** - `2.1.1` - Treat `referral` as optional in custom events. Added new method for custom event tracking. -- **2019-02-19** - `2.1.0` - Handle `referral` in custom events tracking. -- **2018-12-27** - `2.0.0` - Business validation rules. -- **2018-09-05** - `1.6.1` - Request timeout settings -- **2017-11-16** - `1.6.0` - Expose promotion API, Redemptions and Validations namespace update -- **2017-11-16** - `1.5.0` - Expose events API -- **2017-05-07** - `1.4.0` - Segments, Validation rules, API Versioning -- **2017-03-22** - `1.3.0` - improved error handling -- **2017-01-04** - `1.2.0` - added [import vouchers](#import-vouchers) method. -- **2016-12-29** - `1.1.0` - introduced [campaigns api](#campaigns-api) and [products api](#products-api). -- **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) -- **2016-12-02** - `0.8.2` - support gift vouchers in utils, fix price and discount calculations for amount discounts -- **2016-10-03** - `0.8.1` - publish update -- **2016-08-02** - `0.8.0` - validate voucher -- **2016-07-18** - `0.7.0` - voucher udpate -- **2016-07-05** - `0.6.0` - new utils module -- **2016-06-16** - `0.5.0` - unified naming convention -- **2016-06-12** - `0.4.0` - new customer sdk methods -- **2016-05-24** - `0.3.0` - new publish structure -- **2016-04-27** - `0.2.0` - rollback redemption -- **2016-04-13** - `0.1.3` - bugfix in redeem() -- **2016-04-13** - `0.1.2` - removed dependency to `pry` -- **2016-04-12** - `0.1.1` - minor gemspec changes -- **2016-04-12** - `0.1.0` - First version: - - Authentication - - Voucher information: *retrieve voucher*, *list vouchers*, *retrieve redemptions*, *list redemptions* - - Voucher operations: *redeem voucher*, *publish voucher*, *create voucher*, *enable/disable voucher* +## 🌐 Documentation for API Endpoints + +All URIs are relative to *https://api.voucherify.io* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*VoucherifySdk::CampaignsApi* | [**add_voucher_with_specific_code_to_campaign**](docs/CampaignsApi.md#add_voucher_with_specific_code_to_campaign) | **POST** /v1/campaigns/{campaignId}/vouchers/{code} | Add Voucher with Specific Code to Campaign +*VoucherifySdk::CampaignsApi* | [**add_vouchers_to_campaign**](docs/CampaignsApi.md#add_vouchers_to_campaign) | **POST** /v1/campaigns/{campaignId}/vouchers | Add Vouchers to Campaign +*VoucherifySdk::CampaignsApi* | [**create_campaign**](docs/CampaignsApi.md#create_campaign) | **POST** /v1/campaigns | Create Campaign +*VoucherifySdk::CampaignsApi* | [**delete_campaign**](docs/CampaignsApi.md#delete_campaign) | **DELETE** /v1/campaigns/{campaignId} | Delete Campaign +*VoucherifySdk::CampaignsApi* | [**disable_campaign**](docs/CampaignsApi.md#disable_campaign) | **POST** /v1/campaigns/{campaignId}/disable | Disable Campaign +*VoucherifySdk::CampaignsApi* | [**enable_campaign**](docs/CampaignsApi.md#enable_campaign) | **POST** /v1/campaigns/{campaignId}/enable | Enable Campaign +*VoucherifySdk::CampaignsApi* | [**get_campaign**](docs/CampaignsApi.md#get_campaign) | **GET** /v1/campaigns/{campaignId} | Get Campaign +*VoucherifySdk::CampaignsApi* | [**import_vouchers_to_campaign**](docs/CampaignsApi.md#import_vouchers_to_campaign) | **POST** /v1/campaigns/{campaignId}/import | Import Vouchers to Campaign +*VoucherifySdk::CampaignsApi* | [**import_vouchers_to_campaign_using_csv**](docs/CampaignsApi.md#import_vouchers_to_campaign_using_csv) | **POST** /v1/campaigns/{campaignId}/importCSV | Import Vouchers to Campaign by CSV +*VoucherifySdk::CampaignsApi* | [**list_campaigns**](docs/CampaignsApi.md#list_campaigns) | **GET** /v1/campaigns | List Campaigns +*VoucherifySdk::CampaignsApi* | [**update_campaign**](docs/CampaignsApi.md#update_campaign) | **PUT** /v1/campaigns/{campaignId} | Update Campaign +*VoucherifySdk::CategoriesApi* | [**create_category**](docs/CategoriesApi.md#create_category) | **POST** /v1/categories | Create Category +*VoucherifySdk::CategoriesApi* | [**delete_category**](docs/CategoriesApi.md#delete_category) | **DELETE** /v1/categories/{categoryId} | Delete Category +*VoucherifySdk::CategoriesApi* | [**get_category**](docs/CategoriesApi.md#get_category) | **GET** /v1/categories/{categoryId} | Get Category +*VoucherifySdk::CategoriesApi* | [**list_categories**](docs/CategoriesApi.md#list_categories) | **GET** /v1/categories | List Categories +*VoucherifySdk::CategoriesApi* | [**update_category**](docs/CategoriesApi.md#update_category) | **PUT** /v1/categories/{categoryId} | Update Category +*VoucherifySdk::ClientSideApi* | [**check_eligibility_client_side**](docs/ClientSideApi.md#check_eligibility_client_side) | **POST** /client/v1/qualifications | Check Eligibility (client-side) +*VoucherifySdk::ClientSideApi* | [**redeem_stacked_discounts_client_side**](docs/ClientSideApi.md#redeem_stacked_discounts_client_side) | **POST** /client/v1/redemptions | Redeem Stackable Discounts (client-side) +*VoucherifySdk::ClientSideApi* | [**track_custom_event_client_side**](docs/ClientSideApi.md#track_custom_event_client_side) | **POST** /client/v1/events | Track Custom Event (client-side) +*VoucherifySdk::ClientSideApi* | [**update_customers_consents_client_side**](docs/ClientSideApi.md#update_customers_consents_client_side) | **PUT** /client/v1/customers/{customerId}/consents | Update Customer's consents (client-side) +*VoucherifySdk::ClientSideApi* | [**validate_stacked_discounts_client_side**](docs/ClientSideApi.md#validate_stacked_discounts_client_side) | **POST** /client/v1/validations | Validate Stackable Discounts (client-side) +*VoucherifySdk::CustomersApi* | [**create_customer**](docs/CustomersApi.md#create_customer) | **POST** /v1/customers | Create Customer +*VoucherifySdk::CustomersApi* | [**customer_permanently_deletion**](docs/CustomersApi.md#customer_permanently_deletion) | **POST** /v1/customers/{customerId}/permanent-deletion | Delete Customer Permanently +*VoucherifySdk::CustomersApi* | [**delete_customer**](docs/CustomersApi.md#delete_customer) | **DELETE** /v1/customers/{customerId} | Delete Customer +*VoucherifySdk::CustomersApi* | [**get_customer**](docs/CustomersApi.md#get_customer) | **GET** /v1/customers/{customerId} | Get Customer +*VoucherifySdk::CustomersApi* | [**import_customers_using_csv**](docs/CustomersApi.md#import_customers_using_csv) | **POST** /v1/customers/importCSV | Import and Update Customers using CSV +*VoucherifySdk::CustomersApi* | [**list_customer_activities**](docs/CustomersApi.md#list_customer_activities) | **GET** /v1/customers/{customerId}/activities | List Customer Activities +*VoucherifySdk::CustomersApi* | [**list_customer_segments**](docs/CustomersApi.md#list_customer_segments) | **GET** /v1/customers/{customerId}/segments | List Customer's Segments +*VoucherifySdk::CustomersApi* | [**list_customers**](docs/CustomersApi.md#list_customers) | **GET** /v1/customers | List Customers +*VoucherifySdk::CustomersApi* | [**update_customer**](docs/CustomersApi.md#update_customer) | **PUT** /v1/customers/{customerId} | Update Customer +*VoucherifySdk::CustomersApi* | [**update_customers_consents**](docs/CustomersApi.md#update_customers_consents) | **PUT** /v1/customers/{customerId}/consents | Update Customer's consents +*VoucherifySdk::CustomersApi* | [**update_customers_in_bulk**](docs/CustomersApi.md#update_customers_in_bulk) | **POST** /v1/customers/bulk/async | Update Customers in bulk +*VoucherifySdk::CustomersApi* | [**update_customers_metadata_in_bulk**](docs/CustomersApi.md#update_customers_metadata_in_bulk) | **POST** /v1/customers/metadata/async | Update Customers' Metadata in bulk +*VoucherifySdk::EventsApi* | [**track_custom_event**](docs/EventsApi.md#track_custom_event) | **POST** /v1/events | Track Custom Event +*VoucherifySdk::ExportsApi* | [**create_export**](docs/ExportsApi.md#create_export) | **POST** /v1/exports | Create Export +*VoucherifySdk::ExportsApi* | [**delete_export**](docs/ExportsApi.md#delete_export) | **DELETE** /v1/exports/{exportId} | Delete Export +*VoucherifySdk::ExportsApi* | [**download_export**](docs/ExportsApi.md#download_export) | **GET** /v1/exports/{export_Id} | Download Export +*VoucherifySdk::ExportsApi* | [**get_export**](docs/ExportsApi.md#get_export) | **GET** /v1/exports/{exportId} | Get Export +*VoucherifySdk::ExportsApi* | [**list_exports**](docs/ExportsApi.md#list_exports) | **GET** /v1/exports | List Exports +*VoucherifySdk::LoyaltiesApi* | [**create_in_bulk_loyalty_tiers**](docs/LoyaltiesApi.md#create_in_bulk_loyalty_tiers) | **POST** /v1/loyalties/{campaignId}/tiers | Create loyalty tiers +*VoucherifySdk::LoyaltiesApi* | [**delete_earning_rule**](docs/LoyaltiesApi.md#delete_earning_rule) | **DELETE** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId} | Delete Earning Rule +*VoucherifySdk::LoyaltiesApi* | [**delete_loyalty_program**](docs/LoyaltiesApi.md#delete_loyalty_program) | **DELETE** /v1/loyalties/{campaignId} | Delete Loyalty Campaign +*VoucherifySdk::LoyaltiesApi* | [**delete_reward_assignment1**](docs/LoyaltiesApi.md#delete_reward_assignment1) | **DELETE** /v1/loyalties/{campaignId}/rewards/{assignmentId} | Delete Reward Assignment +*VoucherifySdk::LoyaltiesApi* | [**disable_earning_rule**](docs/LoyaltiesApi.md#disable_earning_rule) | **POST** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/disable | Disable Earning Rule +*VoucherifySdk::LoyaltiesApi* | [**enable_earning_rule**](docs/LoyaltiesApi.md#enable_earning_rule) | **POST** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/enable | Enable Earning Rule +*VoucherifySdk::LoyaltiesApi* | [**export_loyalty_card_transactions**](docs/LoyaltiesApi.md#export_loyalty_card_transactions) | **POST** /v1/loyalties/members/{memberId}/transactions/export | Export Loyalty Card Transactions +*VoucherifySdk::LoyaltiesApi* | [**export_loyalty_card_transactions1**](docs/LoyaltiesApi.md#export_loyalty_card_transactions1) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/transactions/export | Export Loyalty Card Transactions +*VoucherifySdk::LoyaltiesApi* | [**get_earning_rule**](docs/LoyaltiesApi.md#get_earning_rule) | **GET** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId} | Get Earning Rule +*VoucherifySdk::LoyaltiesApi* | [**get_loyalty_tier**](docs/LoyaltiesApi.md#get_loyalty_tier) | **GET** /v1/loyalties/{campaignId}/tiers/{loyaltyTierId} | Get Loyalty Tier +*VoucherifySdk::LoyaltiesApi* | [**get_reward_assignment1**](docs/LoyaltiesApi.md#get_reward_assignment1) | **GET** /v1/loyalties/{campaignId}/reward-assignments/{assignmentId} | Get Reward Assignment +*VoucherifySdk::LoyaltiesApi* | [**get_reward_assignment2**](docs/LoyaltiesApi.md#get_reward_assignment2) | **GET** /v1/loyalties/{campaignId}/rewards/{assignmentId} | Get Reward Assignment +*VoucherifySdk::LoyaltiesApi* | [**get_reward_details**](docs/LoyaltiesApi.md#get_reward_details) | **GET** /v1/loyalties/{campaignId}/reward-assignments/{assignmentId}/reward | Get Reward Details +*VoucherifySdk::LoyaltiesApi* | [**list_loyalty_card_transactions**](docs/LoyaltiesApi.md#list_loyalty_card_transactions) | **GET** /v1/loyalties/members/{memberId}/transactions | List Loyalty Card Transactions +*VoucherifySdk::LoyaltiesApi* | [**list_loyalty_card_transactions1**](docs/LoyaltiesApi.md#list_loyalty_card_transactions1) | **GET** /v1/loyalties/{campaignId}/members/{memberId}/transactions | List Loyalty Card Transactions +*VoucherifySdk::LoyaltiesApi* | [**list_loyalty_tier_earning_rules**](docs/LoyaltiesApi.md#list_loyalty_tier_earning_rules) | **GET** /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/earning-rules | List Loyalty Tier Earning Rules +*VoucherifySdk::LoyaltiesApi* | [**list_loyalty_tier_rewards**](docs/LoyaltiesApi.md#list_loyalty_tier_rewards) | **GET** /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/rewards | List Loyalty Tier Rewards +*VoucherifySdk::LoyaltiesApi* | [**list_loyalty_tiers**](docs/LoyaltiesApi.md#list_loyalty_tiers) | **GET** /v1/loyalties/{campaignId}/tiers | List Loyalty Tiers +*VoucherifySdk::LoyaltiesApi* | [**list_member_loyalty_tier**](docs/LoyaltiesApi.md#list_member_loyalty_tier) | **GET** /v1/loyalties/members/{memberId}/tiers | List Member's Loyalty Tiers +*VoucherifySdk::LoyaltiesApi* | [**list_member_rewards**](docs/LoyaltiesApi.md#list_member_rewards) | **GET** /v1/loyalties/members/{memberId}/rewards | List Member Rewards +*VoucherifySdk::LoyaltiesApi* | [**list_points_expiration**](docs/LoyaltiesApi.md#list_points_expiration) | **GET** /v1/loyalties/{campaignId}/members/{memberId}/points-expiration | Get Points Expiration +*VoucherifySdk::LoyaltiesApi* | [**redeem_reward**](docs/LoyaltiesApi.md#redeem_reward) | **POST** /v1/loyalties/members/{memberId}/redemption | Redeem Reward +*VoucherifySdk::LoyaltiesApi* | [**redeem_reward1**](docs/LoyaltiesApi.md#redeem_reward1) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/redemption | Redeem Reward +*VoucherifySdk::LoyaltiesApi* | [**transfer_points**](docs/LoyaltiesApi.md#transfer_points) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/transfers | Transfer Loyalty Points +*VoucherifySdk::LoyaltiesApi* | [**update_loyalty_card_balance**](docs/LoyaltiesApi.md#update_loyalty_card_balance) | **POST** /v1/loyalties/members/{memberId}/balance | Add or Remove Loyalty Card Balance +*VoucherifySdk::LoyaltiesApi* | [**update_loyalty_card_balance1**](docs/LoyaltiesApi.md#update_loyalty_card_balance1) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/balance | Add or Remove Loyalty Card Balance +*VoucherifySdk::OrdersApi* | [**create_order**](docs/OrdersApi.md#create_order) | **POST** /v1/orders | Create Order +*VoucherifySdk::OrdersApi* | [**create_order_export**](docs/OrdersApi.md#create_order_export) | **POST** /v1/orders/export | Create Orders Export +*VoucherifySdk::OrdersApi* | [**get_order**](docs/OrdersApi.md#get_order) | **GET** /v1/orders/{orderId} | Get Order +*VoucherifySdk::OrdersApi* | [**import_orders**](docs/OrdersApi.md#import_orders) | **POST** /v1/orders/import | Import Orders +*VoucherifySdk::OrdersApi* | [**list_orders**](docs/OrdersApi.md#list_orders) | **GET** /v1/orders | List Orders +*VoucherifySdk::OrdersApi* | [**update_order**](docs/OrdersApi.md#update_order) | **PUT** /v1/orders/{orderId} | Update Order +*VoucherifySdk::ProductCollectionsApi* | [**create_product_collection**](docs/ProductCollectionsApi.md#create_product_collection) | **POST** /v1/product-collections | Create Product Collection +*VoucherifySdk::ProductCollectionsApi* | [**delete_product_collection**](docs/ProductCollectionsApi.md#delete_product_collection) | **DELETE** /v1/product-collections/{productCollectionId} | Delete Product Collection +*VoucherifySdk::ProductCollectionsApi* | [**get_product_collection**](docs/ProductCollectionsApi.md#get_product_collection) | **GET** /v1/product-collections/{productCollectionId} | Get Product Collection +*VoucherifySdk::ProductCollectionsApi* | [**list_product_collections**](docs/ProductCollectionsApi.md#list_product_collections) | **GET** /v1/product-collections | List Product Collections +*VoucherifySdk::ProductCollectionsApi* | [**list_products_in_collection**](docs/ProductCollectionsApi.md#list_products_in_collection) | **GET** /v1/product-collections/{productCollectionId}/products | List Products in Collection +*VoucherifySdk::ProductsApi* | [**create_product**](docs/ProductsApi.md#create_product) | **POST** /v1/products | Create Product +*VoucherifySdk::ProductsApi* | [**create_sku**](docs/ProductsApi.md#create_sku) | **POST** /v1/products/{productId}/skus | Create SKU +*VoucherifySdk::ProductsApi* | [**delete_product**](docs/ProductsApi.md#delete_product) | **DELETE** /v1/products/{productId} | Delete Product +*VoucherifySdk::ProductsApi* | [**delete_sku**](docs/ProductsApi.md#delete_sku) | **DELETE** /v1/products/{productId}/skus/{skuId} | Delete SKU +*VoucherifySdk::ProductsApi* | [**get_product**](docs/ProductsApi.md#get_product) | **GET** /v1/products/{productId} | Get Product +*VoucherifySdk::ProductsApi* | [**get_sku**](docs/ProductsApi.md#get_sku) | **GET** /v1/skus/{skuId} | Get SKU +*VoucherifySdk::ProductsApi* | [**import_products_using_csv**](docs/ProductsApi.md#import_products_using_csv) | **POST** /v1/products/importCSV | Import Products using CSV +*VoucherifySdk::ProductsApi* | [**import_skus_using_csv**](docs/ProductsApi.md#import_skus_using_csv) | **POST** /v1/skus/importCSV | Import SKUs using CSV +*VoucherifySdk::ProductsApi* | [**list_products**](docs/ProductsApi.md#list_products) | **GET** /v1/products | List Products +*VoucherifySdk::ProductsApi* | [**list_skus_in_product**](docs/ProductsApi.md#list_skus_in_product) | **GET** /v1/products/{productId}/skus | List SKUs in Product +*VoucherifySdk::ProductsApi* | [**update_product**](docs/ProductsApi.md#update_product) | **PUT** /v1/products/{productId} | Update Product +*VoucherifySdk::ProductsApi* | [**update_products_in_bulk**](docs/ProductsApi.md#update_products_in_bulk) | **POST** /v1/products/bulk/async | Update Products in bulk +*VoucherifySdk::ProductsApi* | [**update_products_metadata_in_bulk**](docs/ProductsApi.md#update_products_metadata_in_bulk) | **POST** /v1/products/metadata/async | Update Products' Metadata in bulk +*VoucherifySdk::ProductsApi* | [**update_sku**](docs/ProductsApi.md#update_sku) | **PUT** /v1/products/{productId}/skus/{skuId} | Update SKU +*VoucherifySdk::PromotionsApi* | [**create_promotion_stack**](docs/PromotionsApi.md#create_promotion_stack) | **POST** /v1/promotions/{campaignId}/stacks | Create Promotion Stack +*VoucherifySdk::PromotionsApi* | [**delete_promotion_stack**](docs/PromotionsApi.md#delete_promotion_stack) | **DELETE** /v1/promotions/{campaignId}/stacks/{stackId} | Delete Promotion Stack +*VoucherifySdk::PromotionsApi* | [**delete_promotion_tier**](docs/PromotionsApi.md#delete_promotion_tier) | **DELETE** /v1/promotions/tiers/{promotionTierId} | Delete Promotion Tier +*VoucherifySdk::PromotionsApi* | [**disable_promotion_tier**](docs/PromotionsApi.md#disable_promotion_tier) | **POST** /v1/promotions/tiers/{promotionTierId}/disable | Disable Promotion Tier +*VoucherifySdk::PromotionsApi* | [**enable_promotion_tier**](docs/PromotionsApi.md#enable_promotion_tier) | **POST** /v1/promotions/tiers/{promotionTierId}/enable | Enable Promotion Tier +*VoucherifySdk::PromotionsApi* | [**get_promotion_stack**](docs/PromotionsApi.md#get_promotion_stack) | **GET** /v1/promotions/{campaignId}/stacks/{stackId} | Get Promotion Stack +*VoucherifySdk::PromotionsApi* | [**get_promotion_tier**](docs/PromotionsApi.md#get_promotion_tier) | **GET** /v1/promotions/tiers/{promotionTierId} | Get Promotion Tier +*VoucherifySdk::PromotionsApi* | [**list_all_promotion_stacks**](docs/PromotionsApi.md#list_all_promotion_stacks) | **GET** /v1/promotions/stacks | List Promotion Stacks +*VoucherifySdk::PromotionsApi* | [**list_promotion_stacks_in_campaign**](docs/PromotionsApi.md#list_promotion_stacks_in_campaign) | **GET** /v1/promotions/{campaignId}/stacks | List Promotion Stacks in Campaign +*VoucherifySdk::PromotionsApi* | [**list_promotion_tiers_from_campaign**](docs/PromotionsApi.md#list_promotion_tiers_from_campaign) | **GET** /v1/promotions/{campaignId}/tiers | List Promotion Tiers from Campaign +*VoucherifySdk::PromotionsApi* | [**update_promotion_stack**](docs/PromotionsApi.md#update_promotion_stack) | **PUT** /v1/promotions/{campaignId}/stacks/{stackId} | Update Promotion Stack +*VoucherifySdk::PublicationsApi* | [**create_publication**](docs/PublicationsApi.md#create_publication) | **POST** /v1/publications | Create Publication +*VoucherifySdk::PublicationsApi* | [**create_publication1**](docs/PublicationsApi.md#create_publication1) | **GET** /v1/publications/create | Create Publication +*VoucherifySdk::PublicationsApi* | [**list_publications**](docs/PublicationsApi.md#list_publications) | **GET** /v1/publications | List Publications +*VoucherifySdk::QualificationsApi* | [**check_eligibility**](docs/QualificationsApi.md#check_eligibility) | **POST** /v1/qualifications | Check Eligibility +*VoucherifySdk::RedemptionsApi* | [**get_redemption**](docs/RedemptionsApi.md#get_redemption) | **GET** /v1/redemptions/{redemptionId} | Get Redemption +*VoucherifySdk::RedemptionsApi* | [**get_voucher_redemptions**](docs/RedemptionsApi.md#get_voucher_redemptions) | **GET** /v1/vouchers/{code}/redemption | Get Voucher's Redemptions +*VoucherifySdk::RedemptionsApi* | [**list_redemptions**](docs/RedemptionsApi.md#list_redemptions) | **GET** /v1/redemptions | List Redemptions +*VoucherifySdk::RedemptionsApi* | [**redeem_stacked_discounts**](docs/RedemptionsApi.md#redeem_stacked_discounts) | **POST** /v1/redemptions | Redeem Stackable Discounts +*VoucherifySdk::RedemptionsApi* | [**rollback_redemption**](docs/RedemptionsApi.md#rollback_redemption) | **POST** /v1/redemptions/{redemptionId}/rollback | Rollback Redemption +*VoucherifySdk::RedemptionsApi* | [**rollback_stacked_redemptions**](docs/RedemptionsApi.md#rollback_stacked_redemptions) | **POST** /v1/redemptions/{parentRedemptionId}/rollbacks | Rollback Stackable Redemptions +*VoucherifySdk::RewardsApi* | [**create_reward_assignment**](docs/RewardsApi.md#create_reward_assignment) | **POST** /v1/rewards/{rewardId}/assignments | Create Reward Assignment +*VoucherifySdk::RewardsApi* | [**delete_reward**](docs/RewardsApi.md#delete_reward) | **DELETE** /v1/rewards/{rewardId} | Delete Reward +*VoucherifySdk::RewardsApi* | [**delete_reward_assignment**](docs/RewardsApi.md#delete_reward_assignment) | **DELETE** /v1/rewards/{rewardId}/assignments/{assignmentId} | Delete Reward Assignment +*VoucherifySdk::RewardsApi* | [**get_reward_assignment**](docs/RewardsApi.md#get_reward_assignment) | **GET** /v1/rewards/{rewardId}/assignments/{assignmentId} | Get Reward Assignment +*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_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 +*VoucherifySdk::ValidationRulesApi* | [**get_validation_rule**](docs/ValidationRulesApi.md#get_validation_rule) | **GET** /v1/validation-rules/{validationRuleId} | Get Validation Rule +*VoucherifySdk::ValidationRulesApi* | [**list_validation_rule_assignments**](docs/ValidationRulesApi.md#list_validation_rule_assignments) | **GET** /v1/validation-rules/{validationRuleId}/assignments | List Validation Rule Assignments +*VoucherifySdk::ValidationRulesApi* | [**list_validation_rules**](docs/ValidationRulesApi.md#list_validation_rules) | **GET** /v1/validation-rules | List Validation Rules +*VoucherifySdk::ValidationRulesApi* | [**list_validation_rules_assignments**](docs/ValidationRulesApi.md#list_validation_rules_assignments) | **GET** /v1/validation-rules-assignments | List Validation Rules' Assignment(s) +*VoucherifySdk::ValidationRulesApi* | [**update_validation_rule**](docs/ValidationRulesApi.md#update_validation_rule) | **PUT** /v1/validation-rules/{validationRuleId} | Update Validation Rule +*VoucherifySdk::ValidationsApi* | [**validate_stacked_discounts**](docs/ValidationsApi.md#validate_stacked_discounts) | **POST** /v1/validations | Validate Stackable Discounts +*VoucherifySdk::VouchersApi* | [**delete_voucher**](docs/VouchersApi.md#delete_voucher) | **DELETE** /v1/vouchers/{code} | Delete Voucher +*VoucherifySdk::VouchersApi* | [**disable_voucher**](docs/VouchersApi.md#disable_voucher) | **POST** /v1/vouchers/{code}/disable | Disable Voucher +*VoucherifySdk::VouchersApi* | [**enable_voucher**](docs/VouchersApi.md#enable_voucher) | **POST** /v1/vouchers/{code}/enable | Enable Voucher +*VoucherifySdk::VouchersApi* | [**export_voucher_transactions**](docs/VouchersApi.md#export_voucher_transactions) | **POST** /v1/vouchers/{code}/transactions/export | Export Voucher Transactions +*VoucherifySdk::VouchersApi* | [**get_voucher**](docs/VouchersApi.md#get_voucher) | **GET** /v1/vouchers/{code} | Get Voucher +*VoucherifySdk::VouchersApi* | [**import_vouchers_using_csv**](docs/VouchersApi.md#import_vouchers_using_csv) | **POST** /v1/vouchers/importCSV | Import Vouchers using CSV +*VoucherifySdk::VouchersApi* | [**list_voucher_transactions**](docs/VouchersApi.md#list_voucher_transactions) | **GET** /v1/vouchers/{code}/transactions | List Voucher Transactions +*VoucherifySdk::VouchersApi* | [**release_validation_session**](docs/VouchersApi.md#release_validation_session) | **DELETE** /v1/vouchers/{code}/sessions/{sessionKey} | Release Validation Session +*VoucherifySdk::VouchersApi* | [**update_voucher_balance**](docs/VouchersApi.md#update_voucher_balance) | **POST** /v1/vouchers/{code}/balance | Add or Remove Voucher Balance + + +## 📚 Documentation for Models + + - [VoucherifySdk::Any](docs/Any.md) + - [VoucherifySdk::ApplicableTo](docs/ApplicableTo.md) + - [VoucherifySdk::ApplicableToEffect](docs/ApplicableToEffect.md) + - [VoucherifySdk::ApplicableToResultList](docs/ApplicableToResultList.md) + - [VoucherifySdk::ArrayInner](docs/ArrayInner.md) + - [VoucherifySdk::AsyncActions](docs/AsyncActions.md) + - [VoucherifySdk::BusValRuleAssignment](docs/BusValRuleAssignment.md) + - [VoucherifySdk::Campaign](docs/Campaign.md) + - [VoucherifySdk::CampaignBase](docs/CampaignBase.md) + - [VoucherifySdk::CampaignBaseValidityTimeframe](docs/CampaignBaseValidityTimeframe.md) + - [VoucherifySdk::CampaignLoyaltyCard](docs/CampaignLoyaltyCard.md) + - [VoucherifySdk::CampaignLoyaltyCardExpirationRules](docs/CampaignLoyaltyCardExpirationRules.md) + - [VoucherifySdk::CampaignLoyaltyVoucher](docs/CampaignLoyaltyVoucher.md) + - [VoucherifySdk::CampaignLoyaltyVoucherRedemption](docs/CampaignLoyaltyVoucherRedemption.md) + - [VoucherifySdk::CampaignVoucher](docs/CampaignVoucher.md) + - [VoucherifySdk::CampaignVoucherRedemption](docs/CampaignVoucherRedemption.md) + - [VoucherifySdk::CampaignsCreateBase](docs/CampaignsCreateBase.md) + - [VoucherifySdk::CampaignsCreateDiscountCouponsCampaign](docs/CampaignsCreateDiscountCouponsCampaign.md) + - [VoucherifySdk::CampaignsCreateGiftCampaign](docs/CampaignsCreateGiftCampaign.md) + - [VoucherifySdk::CampaignsCreateGiveawayCampaign](docs/CampaignsCreateGiveawayCampaign.md) + - [VoucherifySdk::CampaignsCreateLoyaltyCampaign](docs/CampaignsCreateLoyaltyCampaign.md) + - [VoucherifySdk::CampaignsCreatePromotionCampaign](docs/CampaignsCreatePromotionCampaign.md) + - [VoucherifySdk::CampaignsCreateReferralCampaign](docs/CampaignsCreateReferralCampaign.md) + - [VoucherifySdk::CampaignsCreateRequestBody](docs/CampaignsCreateRequestBody.md) + - [VoucherifySdk::CampaignsCreateResponseBody](docs/CampaignsCreateResponseBody.md) + - [VoucherifySdk::CampaignsDeleteResponseBody](docs/CampaignsDeleteResponseBody.md) + - [VoucherifySdk::CampaignsDisableResponseBody](docs/CampaignsDisableResponseBody.md) + - [VoucherifySdk::CampaignsEnableResponseBody](docs/CampaignsEnableResponseBody.md) + - [VoucherifySdk::CampaignsGetResponseBody](docs/CampaignsGetResponseBody.md) + - [VoucherifySdk::CampaignsImportCreateResponseBody](docs/CampaignsImportCreateResponseBody.md) + - [VoucherifySdk::CampaignsImportCsvCreateResponseBody](docs/CampaignsImportCsvCreateResponseBody.md) + - [VoucherifySdk::CampaignsImportVoucherItem](docs/CampaignsImportVoucherItem.md) + - [VoucherifySdk::CampaignsImportVoucherItemRedemption](docs/CampaignsImportVoucherItemRedemption.md) + - [VoucherifySdk::CampaignsImportVoucherLoyaltyCard](docs/CampaignsImportVoucherLoyaltyCard.md) + - [VoucherifySdk::CampaignsListResponseBody](docs/CampaignsListResponseBody.md) + - [VoucherifySdk::CampaignsUpdateBase](docs/CampaignsUpdateBase.md) + - [VoucherifySdk::CampaignsUpdateCouponCampaignBase](docs/CampaignsUpdateCouponCampaignBase.md) + - [VoucherifySdk::CampaignsUpdateDiscountCouponsCampaign](docs/CampaignsUpdateDiscountCouponsCampaign.md) + - [VoucherifySdk::CampaignsUpdateGiftCampaign](docs/CampaignsUpdateGiftCampaign.md) + - [VoucherifySdk::CampaignsUpdateGiveawayCampaign](docs/CampaignsUpdateGiveawayCampaign.md) + - [VoucherifySdk::CampaignsUpdateLoyaltyCampaign](docs/CampaignsUpdateLoyaltyCampaign.md) + - [VoucherifySdk::CampaignsUpdatePromotionCampaign](docs/CampaignsUpdatePromotionCampaign.md) + - [VoucherifySdk::CampaignsUpdateReferralCampaign](docs/CampaignsUpdateReferralCampaign.md) + - [VoucherifySdk::CampaignsUpdateRequestBody](docs/CampaignsUpdateRequestBody.md) + - [VoucherifySdk::CampaignsUpdateResponseBody](docs/CampaignsUpdateResponseBody.md) + - [VoucherifySdk::CampaignsVouchersCreateBaseRequestBody](docs/CampaignsVouchersCreateBaseRequestBody.md) + - [VoucherifySdk::CampaignsVouchersCreateInBulkRequestBody](docs/CampaignsVouchersCreateInBulkRequestBody.md) + - [VoucherifySdk::CampaignsVouchersCreateInBulkResponseBody](docs/CampaignsVouchersCreateInBulkResponseBody.md) + - [VoucherifySdk::CampaignsVouchersCreateRequestBody](docs/CampaignsVouchersCreateRequestBody.md) + - [VoucherifySdk::CampaignsVouchersCreateResponseBody](docs/CampaignsVouchersCreateResponseBody.md) + - [VoucherifySdk::CategoriesCreateRequestBody](docs/CategoriesCreateRequestBody.md) + - [VoucherifySdk::CategoriesCreateResponseBody](docs/CategoriesCreateResponseBody.md) + - [VoucherifySdk::CategoriesGetResponseBody](docs/CategoriesGetResponseBody.md) + - [VoucherifySdk::CategoriesListResponseBody](docs/CategoriesListResponseBody.md) + - [VoucherifySdk::CategoriesUpdateRequestBody](docs/CategoriesUpdateRequestBody.md) + - [VoucherifySdk::CategoriesUpdateResponseBody](docs/CategoriesUpdateResponseBody.md) + - [VoucherifySdk::Category](docs/Category.md) + - [VoucherifySdk::ClientEventsCreateRequestBody](docs/ClientEventsCreateRequestBody.md) + - [VoucherifySdk::ClientEventsCreateRequestBodyLoyalty](docs/ClientEventsCreateRequestBodyLoyalty.md) + - [VoucherifySdk::ClientEventsCreateRequestBodyReferral](docs/ClientEventsCreateRequestBodyReferral.md) + - [VoucherifySdk::ClientEventsCreateResponseBody](docs/ClientEventsCreateResponseBody.md) + - [VoucherifySdk::ClientQualificationsCheckEligibilityRequestBody](docs/ClientQualificationsCheckEligibilityRequestBody.md) + - [VoucherifySdk::ClientQualificationsCheckEligibilityResponseBody](docs/ClientQualificationsCheckEligibilityResponseBody.md) + - [VoucherifySdk::ClientRedemptionsRedeemRequestBody](docs/ClientRedemptionsRedeemRequestBody.md) + - [VoucherifySdk::ClientRedemptionsRedeemRequestBodyAllOfOptions](docs/ClientRedemptionsRedeemRequestBodyAllOfOptions.md) + - [VoucherifySdk::ClientRedemptionsRedeemResponseBody](docs/ClientRedemptionsRedeemResponseBody.md) + - [VoucherifySdk::ClientValidationsValidateRequestBody](docs/ClientValidationsValidateRequestBody.md) + - [VoucherifySdk::ClientValidationsValidateRequestBodyAllOfOptions](docs/ClientValidationsValidateRequestBodyAllOfOptions.md) + - [VoucherifySdk::ClientValidationsValidateResponseBody](docs/ClientValidationsValidateResponseBody.md) + - [VoucherifySdk::CodeConfig](docs/CodeConfig.md) + - [VoucherifySdk::CodeConfigRequiredLengthCharsetPattern](docs/CodeConfigRequiredLengthCharsetPattern.md) + - [VoucherifySdk::CreatePublicationBase](docs/CreatePublicationBase.md) + - [VoucherifySdk::CreatePublicationCampaign](docs/CreatePublicationCampaign.md) + - [VoucherifySdk::CreatePublicationWithCampaign](docs/CreatePublicationWithCampaign.md) + - [VoucherifySdk::CreatePublicationWithSpecificVoucher](docs/CreatePublicationWithSpecificVoucher.md) + - [VoucherifySdk::CustomEvent](docs/CustomEvent.md) + - [VoucherifySdk::CustomEventReferral](docs/CustomEventReferral.md) + - [VoucherifySdk::Customer](docs/Customer.md) + - [VoucherifySdk::CustomerActivity](docs/CustomerActivity.md) + - [VoucherifySdk::CustomerActivityData](docs/CustomerActivityData.md) + - [VoucherifySdk::CustomerBase](docs/CustomerBase.md) + - [VoucherifySdk::CustomerBaseAddress](docs/CustomerBaseAddress.md) + - [VoucherifySdk::CustomerId](docs/CustomerId.md) + - [VoucherifySdk::CustomerLoyalty](docs/CustomerLoyalty.md) + - [VoucherifySdk::CustomerLoyaltyCampaignsValue](docs/CustomerLoyaltyCampaignsValue.md) + - [VoucherifySdk::CustomerReferrals](docs/CustomerReferrals.md) + - [VoucherifySdk::CustomerReferralsCampaignsItem](docs/CustomerReferralsCampaignsItem.md) + - [VoucherifySdk::CustomerResponseDataAssets](docs/CustomerResponseDataAssets.md) + - [VoucherifySdk::CustomerSegmentsList](docs/CustomerSegmentsList.md) + - [VoucherifySdk::CustomerSummary](docs/CustomerSummary.md) + - [VoucherifySdk::CustomerSummaryOrders](docs/CustomerSummaryOrders.md) + - [VoucherifySdk::CustomerSummaryRedemptions](docs/CustomerSummaryRedemptions.md) + - [VoucherifySdk::CustomerSummaryRedemptionsGift](docs/CustomerSummaryRedemptionsGift.md) + - [VoucherifySdk::CustomerSummaryRedemptionsLoyaltyCard](docs/CustomerSummaryRedemptionsLoyaltyCard.md) + - [VoucherifySdk::CustomerWithSummaryLoyaltyReferrals](docs/CustomerWithSummaryLoyaltyReferrals.md) + - [VoucherifySdk::CustomersActivitiesListResponseBody](docs/CustomersActivitiesListResponseBody.md) + - [VoucherifySdk::CustomersCreateRequestBody](docs/CustomersCreateRequestBody.md) + - [VoucherifySdk::CustomersCreateResponseBody](docs/CustomersCreateResponseBody.md) + - [VoucherifySdk::CustomersGetResponseBody](docs/CustomersGetResponseBody.md) + - [VoucherifySdk::CustomersImportCsvCreateResponseBody](docs/CustomersImportCsvCreateResponseBody.md) + - [VoucherifySdk::CustomersListResponseBody](docs/CustomersListResponseBody.md) + - [VoucherifySdk::CustomersMetadataUpdateInBulkRequestBody](docs/CustomersMetadataUpdateInBulkRequestBody.md) + - [VoucherifySdk::CustomersMetadataUpdateInBulkResponseBody](docs/CustomersMetadataUpdateInBulkResponseBody.md) + - [VoucherifySdk::CustomersPermanentDeletionCreateResponseBody](docs/CustomersPermanentDeletionCreateResponseBody.md) + - [VoucherifySdk::CustomersPermanentDeletionCreateResponseBodyDataJson](docs/CustomersPermanentDeletionCreateResponseBodyDataJson.md) + - [VoucherifySdk::CustomersSegmentsListResponseBody](docs/CustomersSegmentsListResponseBody.md) + - [VoucherifySdk::CustomersUpdateInBulkRequestBody](docs/CustomersUpdateInBulkRequestBody.md) + - [VoucherifySdk::CustomersUpdateInBulkResponseBody](docs/CustomersUpdateInBulkResponseBody.md) + - [VoucherifySdk::CustomersUpdateRequestBody](docs/CustomersUpdateRequestBody.md) + - [VoucherifySdk::CustomersUpdateResponseBody](docs/CustomersUpdateResponseBody.md) + - [VoucherifySdk::Discount](docs/Discount.md) + - [VoucherifySdk::DiscountAmount](docs/DiscountAmount.md) + - [VoucherifySdk::DiscountAmountVouchersEffectTypes](docs/DiscountAmountVouchersEffectTypes.md) + - [VoucherifySdk::DiscountCouponsCampaignVoucher](docs/DiscountCouponsCampaignVoucher.md) + - [VoucherifySdk::DiscountFixed](docs/DiscountFixed.md) + - [VoucherifySdk::DiscountFixedVouchersEffectTypes](docs/DiscountFixedVouchersEffectTypes.md) + - [VoucherifySdk::DiscountPercent](docs/DiscountPercent.md) + - [VoucherifySdk::DiscountPercentVouchersEffectTypes](docs/DiscountPercentVouchersEffectTypes.md) + - [VoucherifySdk::DiscountUnit](docs/DiscountUnit.md) + - [VoucherifySdk::DiscountUnitMultiple](docs/DiscountUnitMultiple.md) + - [VoucherifySdk::DiscountUnitMultipleOneUnit](docs/DiscountUnitMultipleOneUnit.md) + - [VoucherifySdk::DiscountUnitVouchersEffectTypes](docs/DiscountUnitVouchersEffectTypes.md) + - [VoucherifySdk::EarningRule](docs/EarningRule.md) + - [VoucherifySdk::EarningRuleBase](docs/EarningRuleBase.md) + - [VoucherifySdk::EarningRuleBaseCustomEvent](docs/EarningRuleBaseCustomEvent.md) + - [VoucherifySdk::EarningRuleBaseLoyalty](docs/EarningRuleBaseLoyalty.md) + - [VoucherifySdk::EarningRuleBaseSegment](docs/EarningRuleBaseSegment.md) + - [VoucherifySdk::EarningRuleBaseSource](docs/EarningRuleBaseSource.md) + - [VoucherifySdk::EarningRuleBaseValidityTimeframe](docs/EarningRuleBaseValidityTimeframe.md) + - [VoucherifySdk::EarningRuleEvent](docs/EarningRuleEvent.md) + - [VoucherifySdk::EarningRuleFixed](docs/EarningRuleFixed.md) + - [VoucherifySdk::EarningRuleProportional](docs/EarningRuleProportional.md) + - [VoucherifySdk::EarningRuleProportionalCustomEvent](docs/EarningRuleProportionalCustomEvent.md) + - [VoucherifySdk::EarningRuleProportionalCustomEventCustomEvent](docs/EarningRuleProportionalCustomEventCustomEvent.md) + - [VoucherifySdk::EarningRuleProportionalCustomEventCustomEventMetadata](docs/EarningRuleProportionalCustomEventCustomEventMetadata.md) + - [VoucherifySdk::EarningRuleProportionalCustomerMetadata](docs/EarningRuleProportionalCustomerMetadata.md) + - [VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomer](docs/EarningRuleProportionalCustomerMetadataCustomer.md) + - [VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomerMetadata](docs/EarningRuleProportionalCustomerMetadataCustomerMetadata.md) + - [VoucherifySdk::EarningRuleProportionalOrder](docs/EarningRuleProportionalOrder.md) + - [VoucherifySdk::EarningRuleProportionalOrderAmount](docs/EarningRuleProportionalOrderAmount.md) + - [VoucherifySdk::EarningRuleProportionalOrderAmountOrder](docs/EarningRuleProportionalOrderAmountOrder.md) + - [VoucherifySdk::EarningRuleProportionalOrderAmountOrderAmount](docs/EarningRuleProportionalOrderAmountOrderAmount.md) + - [VoucherifySdk::EarningRuleProportionalOrderItems](docs/EarningRuleProportionalOrderItems.md) + - [VoucherifySdk::EarningRuleProportionalOrderItemsAmount](docs/EarningRuleProportionalOrderItemsAmount.md) + - [VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItems](docs/EarningRuleProportionalOrderItemsAmountOrderItems.md) + - [VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItemsAmount](docs/EarningRuleProportionalOrderItemsAmountOrderItemsAmount.md) + - [VoucherifySdk::EarningRuleProportionalOrderItemsQuantity](docs/EarningRuleProportionalOrderItemsQuantity.md) + - [VoucherifySdk::EarningRuleProportionalOrderItemsQuantityOrderItems](docs/EarningRuleProportionalOrderItemsQuantityOrderItems.md) + - [VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmount](docs/EarningRuleProportionalOrderItemsSubtotalAmount.md) + - [VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmountOrderItems](docs/EarningRuleProportionalOrderItemsSubtotalAmountOrderItems.md) + - [VoucherifySdk::EarningRuleProportionalOrderMetadata](docs/EarningRuleProportionalOrderMetadata.md) + - [VoucherifySdk::EarningRuleProportionalOrderMetadataOrder](docs/EarningRuleProportionalOrderMetadataOrder.md) + - [VoucherifySdk::EarningRuleProportionalOrderMetadataOrderMetadata](docs/EarningRuleProportionalOrderMetadataOrderMetadata.md) + - [VoucherifySdk::EarningRuleProportionalOrderTotalAmount](docs/EarningRuleProportionalOrderTotalAmount.md) + - [VoucherifySdk::EarningRuleProportionalOrderTotalAmountOrder](docs/EarningRuleProportionalOrderTotalAmountOrder.md) + - [VoucherifySdk::Error](docs/Error.md) + - [VoucherifySdk::EventCustomerActiveCampaignFailed](docs/EventCustomerActiveCampaignFailed.md) + - [VoucherifySdk::EventCustomerActiveCampaignRecovered](docs/EventCustomerActiveCampaignRecovered.md) + - [VoucherifySdk::EventCustomerActiveCampaignSent](docs/EventCustomerActiveCampaignSent.md) + - [VoucherifySdk::EventCustomerBatchFailed](docs/EventCustomerBatchFailed.md) + - [VoucherifySdk::EventCustomerBatchRecovered](docs/EventCustomerBatchRecovered.md) + - [VoucherifySdk::EventCustomerBatchSent](docs/EventCustomerBatchSent.md) + - [VoucherifySdk::EventCustomerBrazeFailed](docs/EventCustomerBrazeFailed.md) + - [VoucherifySdk::EventCustomerBrazeRecovered](docs/EventCustomerBrazeRecovered.md) + - [VoucherifySdk::EventCustomerBrazeSent](docs/EventCustomerBrazeSent.md) + - [VoucherifySdk::EventCustomerConfirmed](docs/EventCustomerConfirmed.md) + - [VoucherifySdk::EventCustomerConfirmedUnconfirmedCustomer](docs/EventCustomerConfirmedUnconfirmedCustomer.md) + - [VoucherifySdk::EventCustomerConsents](docs/EventCustomerConsents.md) + - [VoucherifySdk::EventCustomerConsentsGiven](docs/EventCustomerConsentsGiven.md) + - [VoucherifySdk::EventCustomerConsentsRevoked](docs/EventCustomerConsentsRevoked.md) + - [VoucherifySdk::EventCustomerCreated](docs/EventCustomerCreated.md) + - [VoucherifySdk::EventCustomerCustomEvent](docs/EventCustomerCustomEvent.md) + - [VoucherifySdk::EventCustomerDeleted](docs/EventCustomerDeleted.md) + - [VoucherifySdk::EventCustomerEmailFailed](docs/EventCustomerEmailFailed.md) + - [VoucherifySdk::EventCustomerEmailRecovered](docs/EventCustomerEmailRecovered.md) + - [VoucherifySdk::EventCustomerEmailSent](docs/EventCustomerEmailSent.md) + - [VoucherifySdk::EventCustomerFailed](docs/EventCustomerFailed.md) + - [VoucherifySdk::EventCustomerGiftVoucherBalanceAdded](docs/EventCustomerGiftVoucherBalanceAdded.md) + - [VoucherifySdk::EventCustomerIntercomFailed](docs/EventCustomerIntercomFailed.md) + - [VoucherifySdk::EventCustomerIntercomRecovered](docs/EventCustomerIntercomRecovered.md) + - [VoucherifySdk::EventCustomerIntercomSent](docs/EventCustomerIntercomSent.md) + - [VoucherifySdk::EventCustomerKlaviyoFailed](docs/EventCustomerKlaviyoFailed.md) + - [VoucherifySdk::EventCustomerKlaviyoRecovered](docs/EventCustomerKlaviyoRecovered.md) + - [VoucherifySdk::EventCustomerKlaviyoSent](docs/EventCustomerKlaviyoSent.md) + - [VoucherifySdk::EventCustomerLoyaltyCardPointsAdded](docs/EventCustomerLoyaltyCardPointsAdded.md) + - [VoucherifySdk::EventCustomerLoyaltyCardPointsTransferred](docs/EventCustomerLoyaltyCardPointsTransferred.md) + - [VoucherifySdk::EventCustomerLoyaltyTierBase](docs/EventCustomerLoyaltyTierBase.md) + - [VoucherifySdk::EventCustomerLoyaltyTierDowngraded](docs/EventCustomerLoyaltyTierDowngraded.md) + - [VoucherifySdk::EventCustomerLoyaltyTierExpirationChanged](docs/EventCustomerLoyaltyTierExpirationChanged.md) + - [VoucherifySdk::EventCustomerLoyaltyTierJoined](docs/EventCustomerLoyaltyTierJoined.md) + - [VoucherifySdk::EventCustomerLoyaltyTierLeft](docs/EventCustomerLoyaltyTierLeft.md) + - [VoucherifySdk::EventCustomerLoyaltyTierProlonged](docs/EventCustomerLoyaltyTierProlonged.md) + - [VoucherifySdk::EventCustomerLoyaltyTierUpgraded](docs/EventCustomerLoyaltyTierUpgraded.md) + - [VoucherifySdk::EventCustomerLoyaltyUpdated](docs/EventCustomerLoyaltyUpdated.md) + - [VoucherifySdk::EventCustomerMailchimpFailed](docs/EventCustomerMailchimpFailed.md) + - [VoucherifySdk::EventCustomerMailchimpRecovered](docs/EventCustomerMailchimpRecovered.md) + - [VoucherifySdk::EventCustomerMailchimpSent](docs/EventCustomerMailchimpSent.md) + - [VoucherifySdk::EventCustomerOrder](docs/EventCustomerOrder.md) + - [VoucherifySdk::EventCustomerOrderCanceled](docs/EventCustomerOrderCanceled.md) + - [VoucherifySdk::EventCustomerOrderCreated](docs/EventCustomerOrderCreated.md) + - [VoucherifySdk::EventCustomerOrderFulfilled](docs/EventCustomerOrderFulfilled.md) + - [VoucherifySdk::EventCustomerOrderPaid](docs/EventCustomerOrderPaid.md) + - [VoucherifySdk::EventCustomerOrderProcessing](docs/EventCustomerOrderProcessing.md) + - [VoucherifySdk::EventCustomerOrderUpdated](docs/EventCustomerOrderUpdated.md) + - [VoucherifySdk::EventCustomerPublicationFailed](docs/EventCustomerPublicationFailed.md) + - [VoucherifySdk::EventCustomerPublicationSucceeded](docs/EventCustomerPublicationSucceeded.md) + - [VoucherifySdk::EventCustomerRecovered](docs/EventCustomerRecovered.md) + - [VoucherifySdk::EventCustomerRedemption](docs/EventCustomerRedemption.md) + - [VoucherifySdk::EventCustomerRedemptionFailed](docs/EventCustomerRedemptionFailed.md) + - [VoucherifySdk::EventCustomerRedemptionRollbackFailed](docs/EventCustomerRedemptionRollbackFailed.md) + - [VoucherifySdk::EventCustomerRedemptionRollbackSucceeded](docs/EventCustomerRedemptionRollbackSucceeded.md) + - [VoucherifySdk::EventCustomerRedemptionSucceeded](docs/EventCustomerRedemptionSucceeded.md) + - [VoucherifySdk::EventCustomerReferred](docs/EventCustomerReferred.md) + - [VoucherifySdk::EventCustomerRewardRedemptions](docs/EventCustomerRewardRedemptions.md) + - [VoucherifySdk::EventCustomerRewardRedemptionsCompleted](docs/EventCustomerRewardRedemptionsCompleted.md) + - [VoucherifySdk::EventCustomerRewardRedemptionsCreated](docs/EventCustomerRewardRedemptionsCreated.md) + - [VoucherifySdk::EventCustomerRewardRedemptionsPending](docs/EventCustomerRewardRedemptionsPending.md) + - [VoucherifySdk::EventCustomerRewardRedemptionsRolledBack](docs/EventCustomerRewardRedemptionsRolledBack.md) + - [VoucherifySdk::EventCustomerRewarded](docs/EventCustomerRewarded.md) + - [VoucherifySdk::EventCustomerRewardedLoyaltyPoints](docs/EventCustomerRewardedLoyaltyPoints.md) + - [VoucherifySdk::EventCustomerSegmentEntered](docs/EventCustomerSegmentEntered.md) + - [VoucherifySdk::EventCustomerSegmentLeft](docs/EventCustomerSegmentLeft.md) + - [VoucherifySdk::EventCustomerSent](docs/EventCustomerSent.md) + - [VoucherifySdk::EventCustomerShopifyFailed](docs/EventCustomerShopifyFailed.md) + - [VoucherifySdk::EventCustomerShopifyRecovered](docs/EventCustomerShopifyRecovered.md) + - [VoucherifySdk::EventCustomerShopifySent](docs/EventCustomerShopifySent.md) + - [VoucherifySdk::EventCustomerSmsFailed](docs/EventCustomerSmsFailed.md) + - [VoucherifySdk::EventCustomerSmsRecovered](docs/EventCustomerSmsRecovered.md) + - [VoucherifySdk::EventCustomerSmsSent](docs/EventCustomerSmsSent.md) + - [VoucherifySdk::EventCustomerUpdated](docs/EventCustomerUpdated.md) + - [VoucherifySdk::EventCustomerValidationFailed](docs/EventCustomerValidationFailed.md) + - [VoucherifySdk::EventCustomerValidationSucceeded](docs/EventCustomerValidationSucceeded.md) + - [VoucherifySdk::EventCustomerVoucherDeleted](docs/EventCustomerVoucherDeleted.md) + - [VoucherifySdk::EventCustomerVouchersLoyaltyPointsExpired](docs/EventCustomerVouchersLoyaltyPointsExpired.md) + - [VoucherifySdk::EventsCreateRequestBody](docs/EventsCreateRequestBody.md) + - [VoucherifySdk::EventsCreateResponseBody](docs/EventsCreateResponseBody.md) + - [VoucherifySdk::Export](docs/Export.md) + - [VoucherifySdk::ExportBase](docs/ExportBase.md) + - [VoucherifySdk::ExportBaseResult](docs/ExportBaseResult.md) + - [VoucherifySdk::ExportCustomer](docs/ExportCustomer.md) + - [VoucherifySdk::ExportCustomerBase](docs/ExportCustomerBase.md) + - [VoucherifySdk::ExportCustomerBaseParameters](docs/ExportCustomerBaseParameters.md) + - [VoucherifySdk::ExportCustomerFields](docs/ExportCustomerFields.md) + - [VoucherifySdk::ExportCustomerOrder](docs/ExportCustomerOrder.md) + - [VoucherifySdk::ExportCustomerScheduled](docs/ExportCustomerScheduled.md) + - [VoucherifySdk::ExportOrder](docs/ExportOrder.md) + - [VoucherifySdk::ExportOrderBase](docs/ExportOrderBase.md) + - [VoucherifySdk::ExportOrderFields](docs/ExportOrderFields.md) + - [VoucherifySdk::ExportOrderOrder](docs/ExportOrderOrder.md) + - [VoucherifySdk::ExportOrderScheduled](docs/ExportOrderScheduled.md) + - [VoucherifySdk::ExportPointsExpiration](docs/ExportPointsExpiration.md) + - [VoucherifySdk::ExportPointsExpirationBase](docs/ExportPointsExpirationBase.md) + - [VoucherifySdk::ExportPointsExpirationBaseParameters](docs/ExportPointsExpirationBaseParameters.md) + - [VoucherifySdk::ExportPointsExpirationFields](docs/ExportPointsExpirationFields.md) + - [VoucherifySdk::ExportPointsExpirationFilters](docs/ExportPointsExpirationFilters.md) + - [VoucherifySdk::ExportPointsExpirationOrder](docs/ExportPointsExpirationOrder.md) + - [VoucherifySdk::ExportPointsExpirationScheduled](docs/ExportPointsExpirationScheduled.md) + - [VoucherifySdk::ExportPublication](docs/ExportPublication.md) + - [VoucherifySdk::ExportPublicationBase](docs/ExportPublicationBase.md) + - [VoucherifySdk::ExportPublicationBaseParameters](docs/ExportPublicationBaseParameters.md) + - [VoucherifySdk::ExportPublicationFields](docs/ExportPublicationFields.md) + - [VoucherifySdk::ExportPublicationOrder](docs/ExportPublicationOrder.md) + - [VoucherifySdk::ExportPublicationScheduled](docs/ExportPublicationScheduled.md) + - [VoucherifySdk::ExportRedemption](docs/ExportRedemption.md) + - [VoucherifySdk::ExportRedemptionBase](docs/ExportRedemptionBase.md) + - [VoucherifySdk::ExportRedemptionBaseParameters](docs/ExportRedemptionBaseParameters.md) + - [VoucherifySdk::ExportRedemptionFields](docs/ExportRedemptionFields.md) + - [VoucherifySdk::ExportRedemptionOrder](docs/ExportRedemptionOrder.md) + - [VoucherifySdk::ExportRedemptionScheduled](docs/ExportRedemptionScheduled.md) + - [VoucherifySdk::ExportScheduledBase](docs/ExportScheduledBase.md) + - [VoucherifySdk::ExportVoucher](docs/ExportVoucher.md) + - [VoucherifySdk::ExportVoucherBase](docs/ExportVoucherBase.md) + - [VoucherifySdk::ExportVoucherBaseParameters](docs/ExportVoucherBaseParameters.md) + - [VoucherifySdk::ExportVoucherFields](docs/ExportVoucherFields.md) + - [VoucherifySdk::ExportVoucherOrder](docs/ExportVoucherOrder.md) + - [VoucherifySdk::ExportVoucherScheduled](docs/ExportVoucherScheduled.md) + - [VoucherifySdk::ExportVoucherTransactions](docs/ExportVoucherTransactions.md) + - [VoucherifySdk::ExportVoucherTransactionsBase](docs/ExportVoucherTransactionsBase.md) + - [VoucherifySdk::ExportVoucherTransactionsFields](docs/ExportVoucherTransactionsFields.md) + - [VoucherifySdk::ExportVoucherTransactionsFilters](docs/ExportVoucherTransactionsFilters.md) + - [VoucherifySdk::ExportVoucherTransactionsOrder](docs/ExportVoucherTransactionsOrder.md) + - [VoucherifySdk::ExportVoucherTransactionsScheduled](docs/ExportVoucherTransactionsScheduled.md) + - [VoucherifySdk::ExportsCreateRequestBody](docs/ExportsCreateRequestBody.md) + - [VoucherifySdk::ExportsCreateResponseBody](docs/ExportsCreateResponseBody.md) + - [VoucherifySdk::ExportsGetResponseBody](docs/ExportsGetResponseBody.md) + - [VoucherifySdk::ExportsListResponseBody](docs/ExportsListResponseBody.md) + - [VoucherifySdk::FieldConditions](docs/FieldConditions.md) + - [VoucherifySdk::FilterConditionsString](docs/FilterConditionsString.md) + - [VoucherifySdk::FiltersCondition](docs/FiltersCondition.md) + - [VoucherifySdk::Gift](docs/Gift.md) + - [VoucherifySdk::GiftCampaignVoucher](docs/GiftCampaignVoucher.md) + - [VoucherifySdk::GiveawayCampaignVoucher](docs/GiveawayCampaignVoucher.md) + - [VoucherifySdk::InapplicableTo](docs/InapplicableTo.md) + - [VoucherifySdk::InapplicableToResultList](docs/InapplicableToResultList.md) + - [VoucherifySdk::Junction](docs/Junction.md) + - [VoucherifySdk::ListPublicationsItemBase](docs/ListPublicationsItemBase.md) + - [VoucherifySdk::ListPublicationsItemInvalid](docs/ListPublicationsItemInvalid.md) + - [VoucherifySdk::ListPublicationsItemValidMultipleVouchers](docs/ListPublicationsItemValidMultipleVouchers.md) + - [VoucherifySdk::ListPublicationsItemValidSingleVoucher](docs/ListPublicationsItemValidSingleVoucher.md) + - [VoucherifySdk::ListPublicationsItemVoucher](docs/ListPublicationsItemVoucher.md) + - [VoucherifySdk::LoyaltiesDeleteResponseBody](docs/LoyaltiesDeleteResponseBody.md) + - [VoucherifySdk::LoyaltiesEarningRulesDisableResponseBody](docs/LoyaltiesEarningRulesDisableResponseBody.md) + - [VoucherifySdk::LoyaltiesEarningRulesEnableResponseBody](docs/LoyaltiesEarningRulesEnableResponseBody.md) + - [VoucherifySdk::LoyaltiesEarningRulesGetResponseBody](docs/LoyaltiesEarningRulesGetResponseBody.md) + - [VoucherifySdk::LoyaltiesLoyaltyTierReward](docs/LoyaltiesLoyaltyTierReward.md) + - [VoucherifySdk::LoyaltiesMembersBalanceUpdateRequestBody](docs/LoyaltiesMembersBalanceUpdateRequestBody.md) + - [VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBody](docs/LoyaltiesMembersBalanceUpdateResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject](docs/LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject.md) + - [VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBody](docs/LoyaltiesMembersPointsExpirationListResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItem](docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItem.md) + - [VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket](docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket.md) + - [VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBody](docs/LoyaltiesMembersRedemptionRedeemRequestBody.md) + - [VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBodyReward](docs/LoyaltiesMembersRedemptionRedeemRequestBodyReward.md) + - [VoucherifySdk::LoyaltiesMembersRedemptionRedeemResponseBody](docs/LoyaltiesMembersRedemptionRedeemResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersRewardsListResponseBody](docs/LoyaltiesMembersRewardsListResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersRewardsListResponseBodyDataItem](docs/LoyaltiesMembersRewardsListResponseBodyDataItem.md) + - [VoucherifySdk::LoyaltiesMembersTiersListResponseBody](docs/LoyaltiesMembersTiersListResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBody](docs/LoyaltiesMembersTransactionsExportCreateRequestBody.md) + - [VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBodyParameters](docs/LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md) + - [VoucherifySdk::LoyaltiesMembersTransactionsExportCreateResponseBody](docs/LoyaltiesMembersTransactionsExportCreateResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersTransactionsListResponseBody](docs/LoyaltiesMembersTransactionsListResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBody](docs/LoyaltiesMembersTransfersCreateResponseBody.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssets](docs/LoyaltiesMembersTransfersCreateResponseBodyAssets.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode](docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsQr](docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsQr.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard](docs/LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyPublish](docs/LoyaltiesMembersTransfersCreateResponseBodyPublish.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyRedemption](docs/LoyaltiesMembersTransfersCreateResponseBodyRedemption.md) + - [VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe](docs/LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe.md) + - [VoucherifySdk::LoyaltiesRewardAssignmentsGetResponseBody](docs/LoyaltiesRewardAssignmentsGetResponseBody.md) + - [VoucherifySdk::LoyaltiesRewardAssignmentsRewardGetResponseBody](docs/LoyaltiesRewardAssignmentsRewardGetResponseBody.md) + - [VoucherifySdk::LoyaltiesRewardsGetResponseBody](docs/LoyaltiesRewardsGetResponseBody.md) + - [VoucherifySdk::LoyaltiesTiersCreateInBulkRequestBodyItem](docs/LoyaltiesTiersCreateInBulkRequestBodyItem.md) + - [VoucherifySdk::LoyaltiesTiersEarningRulesListResponseBody](docs/LoyaltiesTiersEarningRulesListResponseBody.md) + - [VoucherifySdk::LoyaltiesTiersGetResponseBody](docs/LoyaltiesTiersGetResponseBody.md) + - [VoucherifySdk::LoyaltiesTiersListResponseBody](docs/LoyaltiesTiersListResponseBody.md) + - [VoucherifySdk::LoyaltiesTiersRewardsListResponseBody](docs/LoyaltiesTiersRewardsListResponseBody.md) + - [VoucherifySdk::LoyaltiesTransferPoints](docs/LoyaltiesTransferPoints.md) + - [VoucherifySdk::LoyaltyCardTransaction](docs/LoyaltyCardTransaction.md) + - [VoucherifySdk::LoyaltyCardTransactionsType](docs/LoyaltyCardTransactionsType.md) + - [VoucherifySdk::LoyaltyTier](docs/LoyaltyTier.md) + - [VoucherifySdk::LoyaltyTierAllOfConfig](docs/LoyaltyTierAllOfConfig.md) + - [VoucherifySdk::LoyaltyTierAllOfConfigPoints](docs/LoyaltyTierAllOfConfigPoints.md) + - [VoucherifySdk::LoyaltyTierBase](docs/LoyaltyTierBase.md) + - [VoucherifySdk::LoyaltyTierBasePoints](docs/LoyaltyTierBasePoints.md) + - [VoucherifySdk::LoyaltyTierExpiration](docs/LoyaltyTierExpiration.md) + - [VoucherifySdk::LoyaltyTiersExpirationAll](docs/LoyaltyTiersExpirationAll.md) + - [VoucherifySdk::LoyaltyTiersExpirationAllExpirationDate](docs/LoyaltyTiersExpirationAllExpirationDate.md) + - [VoucherifySdk::LoyaltyTiersExpirationAllExpirationDateRounding](docs/LoyaltyTiersExpirationAllExpirationDateRounding.md) + - [VoucherifySdk::LoyaltyTiersExpirationAllStartDate](docs/LoyaltyTiersExpirationAllStartDate.md) + - [VoucherifySdk::LuckyDraw](docs/LuckyDraw.md) + - [VoucherifySdk::MappingFixed](docs/MappingFixed.md) + - [VoucherifySdk::MappingMultiply](docs/MappingMultiply.md) + - [VoucherifySdk::MappingPoints](docs/MappingPoints.md) + - [VoucherifySdk::Order](docs/Order.md) + - [VoucherifySdk::OrderBase](docs/OrderBase.md) + - [VoucherifySdk::OrderCalculated](docs/OrderCalculated.md) + - [VoucherifySdk::OrderCalculatedBase](docs/OrderCalculatedBase.md) + - [VoucherifySdk::OrderCalculatedCustomer](docs/OrderCalculatedCustomer.md) + - [VoucherifySdk::OrderCalculatedNoCustomerData](docs/OrderCalculatedNoCustomerData.md) + - [VoucherifySdk::OrderCalculatedReferrer](docs/OrderCalculatedReferrer.md) + - [VoucherifySdk::OrderItem](docs/OrderItem.md) + - [VoucherifySdk::OrderItemCalculated](docs/OrderItemCalculated.md) + - [VoucherifySdk::OrderItemProduct](docs/OrderItemProduct.md) + - [VoucherifySdk::OrderItemSku](docs/OrderItemSku.md) + - [VoucherifySdk::OrderRedemptions](docs/OrderRedemptions.md) + - [VoucherifySdk::OrdersCreateRequestBody](docs/OrdersCreateRequestBody.md) + - [VoucherifySdk::OrdersCreateResponseBody](docs/OrdersCreateResponseBody.md) + - [VoucherifySdk::OrdersExportCreateRequestBody](docs/OrdersExportCreateRequestBody.md) + - [VoucherifySdk::OrdersExportCreateRequestBodyParameters](docs/OrdersExportCreateRequestBodyParameters.md) + - [VoucherifySdk::OrdersExportCreateResponseBody](docs/OrdersExportCreateResponseBody.md) + - [VoucherifySdk::OrdersGetResponseBody](docs/OrdersGetResponseBody.md) + - [VoucherifySdk::OrdersImportCreateRequestBodyItem](docs/OrdersImportCreateRequestBodyItem.md) + - [VoucherifySdk::OrdersImportCreateResponseBody](docs/OrdersImportCreateResponseBody.md) + - [VoucherifySdk::OrdersListResponseBody](docs/OrdersListResponseBody.md) + - [VoucherifySdk::OrdersUpdateRequestBody](docs/OrdersUpdateRequestBody.md) + - [VoucherifySdk::OrdersUpdateResponseBody](docs/OrdersUpdateResponseBody.md) + - [VoucherifySdk::ParameterCampaignType](docs/ParameterCampaignType.md) + - [VoucherifySdk::ParameterCreatedBeforeAfter](docs/ParameterCreatedBeforeAfter.md) + - [VoucherifySdk::ParameterExpandListCampaigns](docs/ParameterExpandListCampaigns.md) + - [VoucherifySdk::ParameterFiltersListRedemptions](docs/ParameterFiltersListRedemptions.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsCampaignName](docs/ParameterFiltersListRedemptionsCampaignName.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsCustomerId](docs/ParameterFiltersListRedemptionsCustomerId.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsFailureCode](docs/ParameterFiltersListRedemptionsFailureCode.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsObject](docs/ParameterFiltersListRedemptionsObject.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsParentRedemptionId](docs/ParameterFiltersListRedemptionsParentRedemptionId.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectId](docs/ParameterFiltersListRedemptionsRelatedObjectId.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectParentId](docs/ParameterFiltersListRedemptionsRelatedObjectParentId.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsResult](docs/ParameterFiltersListRedemptionsResult.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsUserLogin](docs/ParameterFiltersListRedemptionsUserLogin.md) + - [VoucherifySdk::ParameterFiltersListRedemptionsVoucherCode](docs/ParameterFiltersListRedemptionsVoucherCode.md) + - [VoucherifySdk::ParameterOrder](docs/ParameterOrder.md) + - [VoucherifySdk::ParameterOrderListAllPromotionStacks](docs/ParameterOrderListAllPromotionStacks.md) + - [VoucherifySdk::ParameterOrderListCampaigns](docs/ParameterOrderListCampaigns.md) + - [VoucherifySdk::ParameterOrderListCustomers](docs/ParameterOrderListCustomers.md) + - [VoucherifySdk::ParameterOrderListExports](docs/ParameterOrderListExports.md) + - [VoucherifySdk::ParameterOrderListLoyaltyTiers](docs/ParameterOrderListLoyaltyTiers.md) + - [VoucherifySdk::ParameterOrderListOrders](docs/ParameterOrderListOrders.md) + - [VoucherifySdk::ParameterOrderListPublications](docs/ParameterOrderListPublications.md) + - [VoucherifySdk::ParameterOrderListRedemptions](docs/ParameterOrderListRedemptions.md) + - [VoucherifySdk::ParameterOrderListValidationRuleAssignments](docs/ParameterOrderListValidationRuleAssignments.md) + - [VoucherifySdk::ParameterOrderListValidationRules](docs/ParameterOrderListValidationRules.md) + - [VoucherifySdk::ParameterResultListPublications](docs/ParameterResultListPublications.md) + - [VoucherifySdk::ParameterUpdatedBeforeAfter](docs/ParameterUpdatedBeforeAfter.md) + - [VoucherifySdk::ParameterVoucherTypeListPublications](docs/ParameterVoucherTypeListPublications.md) + - [VoucherifySdk::PointsExpirationTypes](docs/PointsExpirationTypes.md) + - [VoucherifySdk::Product](docs/Product.md) + - [VoucherifySdk::ProductCollectionsCreateDynamicRequestBody](docs/ProductCollectionsCreateDynamicRequestBody.md) + - [VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyFilter](docs/ProductCollectionsCreateDynamicRequestBodyFilter.md) + - [VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyProductsItem](docs/ProductCollectionsCreateDynamicRequestBodyProductsItem.md) + - [VoucherifySdk::ProductCollectionsCreateRequestBody](docs/ProductCollectionsCreateRequestBody.md) + - [VoucherifySdk::ProductCollectionsCreateResponseBody](docs/ProductCollectionsCreateResponseBody.md) + - [VoucherifySdk::ProductCollectionsCreateStaticRequestBody](docs/ProductCollectionsCreateStaticRequestBody.md) + - [VoucherifySdk::ProductCollectionsGetResponseBody](docs/ProductCollectionsGetResponseBody.md) + - [VoucherifySdk::ProductCollectionsItem](docs/ProductCollectionsItem.md) + - [VoucherifySdk::ProductCollectionsItemProductsItem](docs/ProductCollectionsItemProductsItem.md) + - [VoucherifySdk::ProductCollectionsList](docs/ProductCollectionsList.md) + - [VoucherifySdk::ProductCollectionsListResponseBody](docs/ProductCollectionsListResponseBody.md) + - [VoucherifySdk::ProductCollectionsProductsList](docs/ProductCollectionsProductsList.md) + - [VoucherifySdk::ProductCollectionsProductsListProductsItem](docs/ProductCollectionsProductsListProductsItem.md) + - [VoucherifySdk::ProductCollectionsProductsListResponseBody](docs/ProductCollectionsProductsListResponseBody.md) + - [VoucherifySdk::ProductWithoutSkus](docs/ProductWithoutSkus.md) + - [VoucherifySdk::ProductsCreateRequestBody](docs/ProductsCreateRequestBody.md) + - [VoucherifySdk::ProductsCreateResponseBody](docs/ProductsCreateResponseBody.md) + - [VoucherifySdk::ProductsGetResponseBody](docs/ProductsGetResponseBody.md) + - [VoucherifySdk::ProductsImportCsvCreateResponseBody](docs/ProductsImportCsvCreateResponseBody.md) + - [VoucherifySdk::ProductsListResponseBody](docs/ProductsListResponseBody.md) + - [VoucherifySdk::ProductsMetadataUpdateInBulkRequestBody](docs/ProductsMetadataUpdateInBulkRequestBody.md) + - [VoucherifySdk::ProductsMetadataUpdateInBulkResponseBody](docs/ProductsMetadataUpdateInBulkResponseBody.md) + - [VoucherifySdk::ProductsSkusCreateRequestBody](docs/ProductsSkusCreateRequestBody.md) + - [VoucherifySdk::ProductsSkusCreateResponseBody](docs/ProductsSkusCreateResponseBody.md) + - [VoucherifySdk::ProductsSkusListResponseBody](docs/ProductsSkusListResponseBody.md) + - [VoucherifySdk::ProductsSkusUpdateRequestBody](docs/ProductsSkusUpdateRequestBody.md) + - [VoucherifySdk::ProductsSkusUpdateResponseBody](docs/ProductsSkusUpdateResponseBody.md) + - [VoucherifySdk::ProductsUpdateInBulkRequestBody](docs/ProductsUpdateInBulkRequestBody.md) + - [VoucherifySdk::ProductsUpdateInBulkResponseBody](docs/ProductsUpdateInBulkResponseBody.md) + - [VoucherifySdk::ProductsUpdateRequestBody](docs/ProductsUpdateRequestBody.md) + - [VoucherifySdk::ProductsUpdateResponseBody](docs/ProductsUpdateResponseBody.md) + - [VoucherifySdk::PromotionStack](docs/PromotionStack.md) + - [VoucherifySdk::PromotionStackBase](docs/PromotionStackBase.md) + - [VoucherifySdk::PromotionStackBaseTiers](docs/PromotionStackBaseTiers.md) + - [VoucherifySdk::PromotionTier](docs/PromotionTier.md) + - [VoucherifySdk::PromotionTierAction](docs/PromotionTierAction.md) + - [VoucherifySdk::PromotionTierCampaign](docs/PromotionTierCampaign.md) + - [VoucherifySdk::PromotionTierCampaignValidityTimeframe](docs/PromotionTierCampaignValidityTimeframe.md) + - [VoucherifySdk::PromotionTierCreateParams](docs/PromotionTierCreateParams.md) + - [VoucherifySdk::PromotionTierSummary](docs/PromotionTierSummary.md) + - [VoucherifySdk::PromotionTierSummaryOrders](docs/PromotionTierSummaryOrders.md) + - [VoucherifySdk::PromotionTierSummaryRedemptions](docs/PromotionTierSummaryRedemptions.md) + - [VoucherifySdk::PromotionTierValidityTimeframe](docs/PromotionTierValidityTimeframe.md) + - [VoucherifySdk::PromotionTiersList](docs/PromotionTiersList.md) + - [VoucherifySdk::PromotionsStacksCreateRequestBody](docs/PromotionsStacksCreateRequestBody.md) + - [VoucherifySdk::PromotionsStacksCreateResponseBody](docs/PromotionsStacksCreateResponseBody.md) + - [VoucherifySdk::PromotionsStacksGetResponseBody](docs/PromotionsStacksGetResponseBody.md) + - [VoucherifySdk::PromotionsStacksListResponseBody](docs/PromotionsStacksListResponseBody.md) + - [VoucherifySdk::PromotionsStacksUpdateRequestBody](docs/PromotionsStacksUpdateRequestBody.md) + - [VoucherifySdk::PromotionsStacksUpdateRequestBodyTiers](docs/PromotionsStacksUpdateRequestBodyTiers.md) + - [VoucherifySdk::PromotionsStacksUpdateResponseBody](docs/PromotionsStacksUpdateResponseBody.md) + - [VoucherifySdk::PromotionsTiersDisableResponseBody](docs/PromotionsTiersDisableResponseBody.md) + - [VoucherifySdk::PromotionsTiersEnableResponseBody](docs/PromotionsTiersEnableResponseBody.md) + - [VoucherifySdk::PromotionsTiersGetResponseBody](docs/PromotionsTiersGetResponseBody.md) + - [VoucherifySdk::PromotionsTiersListResponseBody](docs/PromotionsTiersListResponseBody.md) + - [VoucherifySdk::PropertiesForLoyaltyCampaignOptions](docs/PropertiesForLoyaltyCampaignOptions.md) + - [VoucherifySdk::PublicationsCreateBaseResponseBody](docs/PublicationsCreateBaseResponseBody.md) + - [VoucherifySdk::PublicationsCreateRequestBody](docs/PublicationsCreateRequestBody.md) + - [VoucherifySdk::PublicationsCreateResponseBody](docs/PublicationsCreateResponseBody.md) + - [VoucherifySdk::PublicationsCreateVoucherResponseBody](docs/PublicationsCreateVoucherResponseBody.md) + - [VoucherifySdk::PublicationsCreateVouchersResponseBody](docs/PublicationsCreateVouchersResponseBody.md) + - [VoucherifySdk::PublicationsListResponseBody](docs/PublicationsListResponseBody.md) + - [VoucherifySdk::PublicationsListResponseBodyPublicationsItem](docs/PublicationsListResponseBodyPublicationsItem.md) + - [VoucherifySdk::QualificationsCheckEligibilityRequestBody](docs/QualificationsCheckEligibilityRequestBody.md) + - [VoucherifySdk::QualificationsCheckEligibilityResponseBody](docs/QualificationsCheckEligibilityResponseBody.md) + - [VoucherifySdk::QualificationsFieldConditions](docs/QualificationsFieldConditions.md) + - [VoucherifySdk::QualificationsFiltersCondition](docs/QualificationsFiltersCondition.md) + - [VoucherifySdk::QualificationsOption](docs/QualificationsOption.md) + - [VoucherifySdk::QualificationsOptionFilters](docs/QualificationsOptionFilters.md) + - [VoucherifySdk::QualificationsOptionFiltersResourceType](docs/QualificationsOptionFiltersResourceType.md) + - [VoucherifySdk::QualificationsOptionFiltersResourceTypeConditions](docs/QualificationsOptionFiltersResourceTypeConditions.md) + - [VoucherifySdk::QualificationsRedeemable](docs/QualificationsRedeemable.md) + - [VoucherifySdk::QualificationsRedeemableBase](docs/QualificationsRedeemableBase.md) + - [VoucherifySdk::QualificationsRedeemables](docs/QualificationsRedeemables.md) + - [VoucherifySdk::RedeemGiftCard](docs/RedeemGiftCard.md) + - [VoucherifySdk::RedeemGiftCardAllOfGift](docs/RedeemGiftCardAllOfGift.md) + - [VoucherifySdk::RedeemLoyaltyCard](docs/RedeemLoyaltyCard.md) + - [VoucherifySdk::RedeemLoyaltyCardAllOfReward](docs/RedeemLoyaltyCardAllOfReward.md) + - [VoucherifySdk::RedeemPromotionStack](docs/RedeemPromotionStack.md) + - [VoucherifySdk::RedeemPromotionTier](docs/RedeemPromotionTier.md) + - [VoucherifySdk::RedeemVoucher](docs/RedeemVoucher.md) + - [VoucherifySdk::RedeemableGift](docs/RedeemableGift.md) + - [VoucherifySdk::RedeemableLoyaltyCard](docs/RedeemableLoyaltyCard.md) + - [VoucherifySdk::RedeemableResult](docs/RedeemableResult.md) + - [VoucherifySdk::RedeemableResultGiftCard](docs/RedeemableResultGiftCard.md) + - [VoucherifySdk::RedeemableResultGiftCardGift](docs/RedeemableResultGiftCardGift.md) + - [VoucherifySdk::RedeemableResultLoyaltyCard](docs/RedeemableResultLoyaltyCard.md) + - [VoucherifySdk::RedeemableResultLoyaltyCardLoyaltyCard](docs/RedeemableResultLoyaltyCardLoyaltyCard.md) + - [VoucherifySdk::RedeemableResultPromotionStack](docs/RedeemableResultPromotionStack.md) + - [VoucherifySdk::RedeemableResultPromotionTier](docs/RedeemableResultPromotionTier.md) + - [VoucherifySdk::RedeemableResultPromotionTierDiscount](docs/RedeemableResultPromotionTierDiscount.md) + - [VoucherifySdk::RedeemableResultVoucherCode](docs/RedeemableResultVoucherCode.md) + - [VoucherifySdk::Redemption](docs/Redemption.md) + - [VoucherifySdk::RedemptionChannel](docs/RedemptionChannel.md) + - [VoucherifySdk::RedemptionGift](docs/RedemptionGift.md) + - [VoucherifySdk::RedemptionInternal](docs/RedemptionInternal.md) + - [VoucherifySdk::RedemptionInternalRelatedRedemptions](docs/RedemptionInternalRelatedRedemptions.md) + - [VoucherifySdk::RedemptionInternalRelatedRedemptionsItem](docs/RedemptionInternalRelatedRedemptionsItem.md) + - [VoucherifySdk::RedemptionInternalRelatedRedemptionsRollbacksItem](docs/RedemptionInternalRelatedRedemptionsRollbacksItem.md) + - [VoucherifySdk::RedemptionLoyaltyCard](docs/RedemptionLoyaltyCard.md) + - [VoucherifySdk::RedemptionRelatedRedemptions](docs/RedemptionRelatedRedemptions.md) + - [VoucherifySdk::RedemptionRelatedRedemptionsItem](docs/RedemptionRelatedRedemptionsItem.md) + - [VoucherifySdk::RedemptionRelatedRedemptionsRollbacksItem](docs/RedemptionRelatedRedemptionsRollbacksItem.md) + - [VoucherifySdk::RedemptionRewardResult](docs/RedemptionRewardResult.md) + - [VoucherifySdk::RedemptionRewardResultParameters](docs/RedemptionRewardResultParameters.md) + - [VoucherifySdk::RedemptionRewardResultParametersCampaign](docs/RedemptionRewardResultParametersCampaign.md) + - [VoucherifySdk::RedemptionRewardResultParametersCoin](docs/RedemptionRewardResultParametersCoin.md) + - [VoucherifySdk::RedemptionRewardResultParametersProduct](docs/RedemptionRewardResultParametersProduct.md) + - [VoucherifySdk::RedemptionRewardResultProduct](docs/RedemptionRewardResultProduct.md) + - [VoucherifySdk::RedemptionRewardResultSku](docs/RedemptionRewardResultSku.md) + - [VoucherifySdk::RedemptionRewardResultVoucher](docs/RedemptionRewardResultVoucher.md) + - [VoucherifySdk::RedemptionRollback](docs/RedemptionRollback.md) + - [VoucherifySdk::RedemptionRollbackRelatedRedemptions](docs/RedemptionRollbackRelatedRedemptions.md) + - [VoucherifySdk::RedemptionRollbackRelatedRedemptionsItem](docs/RedemptionRollbackRelatedRedemptionsItem.md) + - [VoucherifySdk::RedemptionRollbackRelatedRedemptionsRollbacksItem](docs/RedemptionRollbackRelatedRedemptionsRollbacksItem.md) + - [VoucherifySdk::RedemptionsGetResponseBody](docs/RedemptionsGetResponseBody.md) + - [VoucherifySdk::RedemptionsListResponseBody](docs/RedemptionsListResponseBody.md) + - [VoucherifySdk::RedemptionsListResponseBodyRedemptionsItem](docs/RedemptionsListResponseBodyRedemptionsItem.md) + - [VoucherifySdk::RedemptionsRedeemRequestBody](docs/RedemptionsRedeemRequestBody.md) + - [VoucherifySdk::RedemptionsRedeemResponseBody](docs/RedemptionsRedeemResponseBody.md) + - [VoucherifySdk::RedemptionsRollbackCreateRequestBody](docs/RedemptionsRollbackCreateRequestBody.md) + - [VoucherifySdk::RedemptionsRollbackCreateResponseBody](docs/RedemptionsRollbackCreateResponseBody.md) + - [VoucherifySdk::RedemptionsRollbacksCreateRequestBody](docs/RedemptionsRollbacksCreateRequestBody.md) + - [VoucherifySdk::RedemptionsRollbacksCreateResponseBody](docs/RedemptionsRollbacksCreateResponseBody.md) + - [VoucherifySdk::ReferralCampaignVoucher](docs/ReferralCampaignVoucher.md) + - [VoucherifySdk::ReferralProgram](docs/ReferralProgram.md) + - [VoucherifySdk::ReferralProgramCustomEvent](docs/ReferralProgramCustomEvent.md) + - [VoucherifySdk::ReferralProgramRefereeReward](docs/ReferralProgramRefereeReward.md) + - [VoucherifySdk::ReferralProgramRefereeRewardRelatedObjectParent](docs/ReferralProgramRefereeRewardRelatedObjectParent.md) + - [VoucherifySdk::Referrer](docs/Referrer.md) + - [VoucherifySdk::ReferrerId](docs/ReferrerId.md) + - [VoucherifySdk::ReferrerWithSummaryLoyaltyReferrals](docs/ReferrerWithSummaryLoyaltyReferrals.md) + - [VoucherifySdk::ResourceTypes](docs/ResourceTypes.md) + - [VoucherifySdk::Reward](docs/Reward.md) + - [VoucherifySdk::RewardAssignment](docs/RewardAssignment.md) + - [VoucherifySdk::RewardAssignmentBase](docs/RewardAssignmentBase.md) + - [VoucherifySdk::RewardAssignmentParameters](docs/RewardAssignmentParameters.md) + - [VoucherifySdk::RewardAssignmentParametersParameters](docs/RewardAssignmentParametersParameters.md) + - [VoucherifySdk::RewardAssignmentParametersParametersLoyalty](docs/RewardAssignmentParametersParametersLoyalty.md) + - [VoucherifySdk::RewardAssignmentsCreateCoinRewardRequestBody](docs/RewardAssignmentsCreateCoinRewardRequestBody.md) + - [VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody](docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody.md) + - [VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters](docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters.md) + - [VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty](docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty.md) + - [VoucherifySdk::RewardAttributes](docs/RewardAttributes.md) + - [VoucherifySdk::RewardType](docs/RewardType.md) + - [VoucherifySdk::RewardTypeCampaign](docs/RewardTypeCampaign.md) + - [VoucherifySdk::RewardTypeCampaignCampaign](docs/RewardTypeCampaignCampaign.md) + - [VoucherifySdk::RewardTypeCoin](docs/RewardTypeCoin.md) + - [VoucherifySdk::RewardTypeCoinCoin](docs/RewardTypeCoinCoin.md) + - [VoucherifySdk::RewardTypeMaterial](docs/RewardTypeMaterial.md) + - [VoucherifySdk::RewardTypeMaterialProduct](docs/RewardTypeMaterialProduct.md) + - [VoucherifySdk::RewardsAssignmentsCreateRequestBody](docs/RewardsAssignmentsCreateRequestBody.md) + - [VoucherifySdk::RewardsAssignmentsCreateResponseBody](docs/RewardsAssignmentsCreateResponseBody.md) + - [VoucherifySdk::RewardsAssignmentsGetResponseBody](docs/RewardsAssignmentsGetResponseBody.md) + - [VoucherifySdk::RewardsAssignmentsListResponseBody](docs/RewardsAssignmentsListResponseBody.md) + - [VoucherifySdk::RewardsAssignmentsUpdateRequestBody](docs/RewardsAssignmentsUpdateRequestBody.md) + - [VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParameters](docs/RewardsAssignmentsUpdateRequestBodyParameters.md) + - [VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParametersLoyalty](docs/RewardsAssignmentsUpdateRequestBodyParametersLoyalty.md) + - [VoucherifySdk::RewardsAssignmentsUpdateResponseBody](docs/RewardsAssignmentsUpdateResponseBody.md) + - [VoucherifySdk::SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion](docs/SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion.md) + - [VoucherifySdk::Session](docs/Session.md) + - [VoucherifySdk::SimpleCampaign](docs/SimpleCampaign.md) + - [VoucherifySdk::SimpleConsent](docs/SimpleConsent.md) + - [VoucherifySdk::SimpleCustomer](docs/SimpleCustomer.md) + - [VoucherifySdk::SimpleCustomerRequiredObjectType](docs/SimpleCustomerRequiredObjectType.md) + - [VoucherifySdk::SimpleOrder](docs/SimpleOrder.md) + - [VoucherifySdk::SimpleOrderItem](docs/SimpleOrderItem.md) + - [VoucherifySdk::SimpleProduct](docs/SimpleProduct.md) + - [VoucherifySdk::SimpleProductDiscountUnit](docs/SimpleProductDiscountUnit.md) + - [VoucherifySdk::SimplePromotionTier](docs/SimplePromotionTier.md) + - [VoucherifySdk::SimplePromotionTierCampaign](docs/SimplePromotionTierCampaign.md) + - [VoucherifySdk::SimpleRedemption](docs/SimpleRedemption.md) + - [VoucherifySdk::SimpleRedemptionRewardResult](docs/SimpleRedemptionRewardResult.md) + - [VoucherifySdk::SimpleReferralTier](docs/SimpleReferralTier.md) + - [VoucherifySdk::SimpleSegment](docs/SimpleSegment.md) + - [VoucherifySdk::SimpleSku](docs/SimpleSku.md) + - [VoucherifySdk::SimpleSkuDiscountUnit](docs/SimpleSkuDiscountUnit.md) + - [VoucherifySdk::SimpleVoucher](docs/SimpleVoucher.md) + - [VoucherifySdk::Sku](docs/Sku.md) + - [VoucherifySdk::SkuWithProduct](docs/SkuWithProduct.md) + - [VoucherifySdk::SkusGetResponseBody](docs/SkusGetResponseBody.md) + - [VoucherifySdk::SkusImportCsvCreateResponseBody](docs/SkusImportCsvCreateResponseBody.md) + - [VoucherifySdk::SkusList](docs/SkusList.md) + - [VoucherifySdk::SkusListForProduct](docs/SkusListForProduct.md) + - [VoucherifySdk::StackableValidateRedeemBase](docs/StackableValidateRedeemBase.md) + - [VoucherifySdk::StackableValidateRedeemBaseRedeemablesItem](docs/StackableValidateRedeemBaseRedeemablesItem.md) + - [VoucherifySdk::StackingRules](docs/StackingRules.md) + - [VoucherifySdk::ValidationEntity](docs/ValidationEntity.md) + - [VoucherifySdk::ValidationRule](docs/ValidationRule.md) + - [VoucherifySdk::ValidationRuleAssignment](docs/ValidationRuleAssignment.md) + - [VoucherifySdk::ValidationRuleAssignmentsList](docs/ValidationRuleAssignmentsList.md) + - [VoucherifySdk::ValidationRuleBase](docs/ValidationRuleBase.md) + - [VoucherifySdk::ValidationRuleBaseApplicableTo](docs/ValidationRuleBaseApplicableTo.md) + - [VoucherifySdk::ValidationRuleBaseError](docs/ValidationRuleBaseError.md) + - [VoucherifySdk::ValidationRulesAssignmentsList](docs/ValidationRulesAssignmentsList.md) + - [VoucherifySdk::ValidationRulesAssignmentsListResponseBody](docs/ValidationRulesAssignmentsListResponseBody.md) + - [VoucherifySdk::ValidationRulesCreateRequestBody](docs/ValidationRulesCreateRequestBody.md) + - [VoucherifySdk::ValidationRulesCreateResponseBody](docs/ValidationRulesCreateResponseBody.md) + - [VoucherifySdk::ValidationRulesGetResponseBody](docs/ValidationRulesGetResponseBody.md) + - [VoucherifySdk::ValidationRulesListResponseBody](docs/ValidationRulesListResponseBody.md) + - [VoucherifySdk::ValidationRulesUpdateRequestBody](docs/ValidationRulesUpdateRequestBody.md) + - [VoucherifySdk::ValidationRulesUpdateResponseBody](docs/ValidationRulesUpdateResponseBody.md) + - [VoucherifySdk::ValidationsRedeemableApplicable](docs/ValidationsRedeemableApplicable.md) + - [VoucherifySdk::ValidationsRedeemableApplicableResult](docs/ValidationsRedeemableApplicableResult.md) + - [VoucherifySdk::ValidationsRedeemableInapplicable](docs/ValidationsRedeemableInapplicable.md) + - [VoucherifySdk::ValidationsRedeemableInapplicableResult](docs/ValidationsRedeemableInapplicableResult.md) + - [VoucherifySdk::ValidationsRedeemableSkipped](docs/ValidationsRedeemableSkipped.md) + - [VoucherifySdk::ValidationsValidateAllResponseBodyRedeemablesItem](docs/ValidationsValidateAllResponseBodyRedeemablesItem.md) + - [VoucherifySdk::ValidationsValidateRequestBody](docs/ValidationsValidateRequestBody.md) + - [VoucherifySdk::ValidationsValidateResponseBody](docs/ValidationsValidateResponseBody.md) + - [VoucherifySdk::Voucher](docs/Voucher.md) + - [VoucherifySdk::VoucherAssets](docs/VoucherAssets.md) + - [VoucherifySdk::VoucherGift](docs/VoucherGift.md) + - [VoucherifySdk::VoucherLoyaltyCard](docs/VoucherLoyaltyCard.md) + - [VoucherifySdk::VoucherPublish](docs/VoucherPublish.md) + - [VoucherifySdk::VoucherRedemption](docs/VoucherRedemption.md) + - [VoucherifySdk::VoucherTransaction](docs/VoucherTransaction.md) + - [VoucherifySdk::VoucherTransactionDetails](docs/VoucherTransactionDetails.md) + - [VoucherifySdk::VoucherTransactionDetailsBalance](docs/VoucherTransactionDetailsBalance.md) + - [VoucherifySdk::VoucherTransactionDetailsBalanceRelatedObject](docs/VoucherTransactionDetailsBalanceRelatedObject.md) + - [VoucherifySdk::VoucherTransactionDetailsCustomEvent](docs/VoucherTransactionDetailsCustomEvent.md) + - [VoucherifySdk::VoucherTransactionDetailsEarningRule](docs/VoucherTransactionDetailsEarningRule.md) + - [VoucherifySdk::VoucherTransactionDetailsEarningRuleSource](docs/VoucherTransactionDetailsEarningRuleSource.md) + - [VoucherifySdk::VoucherTransactionDetailsEvent](docs/VoucherTransactionDetailsEvent.md) + - [VoucherifySdk::VoucherTransactionDetailsEventSchema](docs/VoucherTransactionDetailsEventSchema.md) + - [VoucherifySdk::VoucherTransactionDetailsLoyaltyTier](docs/VoucherTransactionDetailsLoyaltyTier.md) + - [VoucherifySdk::VoucherTransactionDetailsOrder](docs/VoucherTransactionDetailsOrder.md) + - [VoucherifySdk::VoucherTransactionDetailsRedemption](docs/VoucherTransactionDetailsRedemption.md) + - [VoucherifySdk::VoucherTransactionDetailsReward](docs/VoucherTransactionDetailsReward.md) + - [VoucherifySdk::VoucherTransactionDetailsRollback](docs/VoucherTransactionDetailsRollback.md) + - [VoucherifySdk::VoucherTransactionDetailsSegment](docs/VoucherTransactionDetailsSegment.md) + - [VoucherifySdk::VoucherTransactionsExport](docs/VoucherTransactionsExport.md) + - [VoucherifySdk::VoucherTransactionsExportFilterConditions](docs/VoucherTransactionsExportFilterConditions.md) + - [VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherId](docs/VoucherTransactionsExportFilterConditionsVoucherId.md) + - [VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherIdConditions](docs/VoucherTransactionsExportFilterConditionsVoucherIdConditions.md) + - [VoucherifySdk::VoucherTransactionsExportParameters](docs/VoucherTransactionsExportParameters.md) + - [VoucherifySdk::VoucherTransactionsExportResult](docs/VoucherTransactionsExportResult.md) + - [VoucherifySdk::VoucherTransactionsFilters](docs/VoucherTransactionsFilters.md) + - [VoucherifySdk::VoucherValidityTimeframe](docs/VoucherValidityTimeframe.md) + - [VoucherifySdk::VouchersBalanceUpdateRequestBody](docs/VouchersBalanceUpdateRequestBody.md) + - [VoucherifySdk::VouchersBalanceUpdateResponseBody](docs/VouchersBalanceUpdateResponseBody.md) + - [VoucherifySdk::VouchersBalanceUpdateResponseBodyRelatedObject](docs/VouchersBalanceUpdateResponseBodyRelatedObject.md) + - [VoucherifySdk::VouchersDisableResponseBody](docs/VouchersDisableResponseBody.md) + - [VoucherifySdk::VouchersEnableResponseBody](docs/VouchersEnableResponseBody.md) + - [VoucherifySdk::VouchersGetResponseBody](docs/VouchersGetResponseBody.md) + - [VoucherifySdk::VouchersImportCsvCreateResponseBody](docs/VouchersImportCsvCreateResponseBody.md) + - [VoucherifySdk::VouchersRedemptionGetResponseBody](docs/VouchersRedemptionGetResponseBody.md) + - [VoucherifySdk::VouchersRedemptionGetResponseBodyRedemptionEntriesItem](docs/VouchersRedemptionGetResponseBodyRedemptionEntriesItem.md) + - [VoucherifySdk::VouchersTransactionsExportCreateRequestBody](docs/VouchersTransactionsExportCreateRequestBody.md) + - [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). - -[Get Async Action]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-async-actions-1 -[List Async Actions]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-async-actions - -[Create Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-voucher -[Get Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-get -[Update Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-voucher -[Delete Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-voucher -[List Vouchers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-vouchers -[Enable Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#enable-voucher -[Disable Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#disable-voucher -[Import Vouchers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#import-vouchers-1 -[Add Gift Voucher Balance]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-gift-voucher-balance - -[Create Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-campaign -[Get Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-campaign -[Add Voucher to Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-voucher-to-campaign -[Import Vouchers to Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#import-vouchers - -[Publish Vouchers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-publication -[Create Export]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-export -[Get Export]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-export -[Delete Export]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-export -[List Publications]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-publications -[Create Publication]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-publication - -[Validate Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#validate-voucher - -[Redeem Voucher]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-voucher -[List Redemptions]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-redemptions -[Get Voucher's Redemptions]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-redemptions -[Get Redemption]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-redemption -[Rollback Redemption]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#rollback-redemption - -[Create Promotion Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-promotion-campaign -[Validate Promotion Campaign]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#validate-promotions-1 -[List Promotion's Tiers]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-promotions -[Create Promotion's Tier]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-promotion-tier-to-campaign -[Redeem Promotion's Tier]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-promotion -[Update Promotion's Tier]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-promotion -[Delete Promotion's Tier]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-promotion - -[Create Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-customer -[Get Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#read-customer -[Update Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-customer -[Delete Customer]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-customer - -[Create Product]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-product -[Get Product]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-product -[Update Product]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-product -[Delete Product]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-product -[List Products]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-products -[Create SKU]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-sku -[Get SKU]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-sku -[Update SKU]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-sku -[Delete SKU]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-sku -[List all product SKUs]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-skus - -[Create Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-validation-rules -[Get Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-validation-rules -[List Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-validation-rules -[Update Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-validation-rules -[Delete Validation Rules]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-validation-rules -[Create Validation Rule Assignment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-validation-rules-assignment -[Delete Validation Rule Assignment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-validation-rules-assignment -[List Validation Rule Assignments]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-validation-rule-assignments - -[Create Segment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-segment -[Get Segment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-segment -[Delete Segment]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-segment - -[Events]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-custom-event-object -[Create event]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-custom-event - -[Create Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-order -[Get Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-order -[Update Order]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-order -[List orders]: https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-orders - -[Create Rewards]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward -[Get Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-reward -[Update Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward -[List Rewards]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-rewards -[Delete Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward -[List Reward Assignments]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-reward-assignments -[Create Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward-assgnment -[Update Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward-assignment -[Delete Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward-assignment - -[List Loyalties]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-loyalty-programs -[Create Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-loyalty-program -[Get Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-loyalty-program -[Update Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-loyalty-program -[Delete Loyalty]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-loyalty-program - -[List Loyalty Reward Assignments]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-reward-assignments-1 -[Create Loyalty Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward-assignment-1 -[Update Loyalty Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward-assignment-1 -[Delete Loyalty Reward Assignment]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward-assignment-1 - -[List Loyalty Earning Rules]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-earning-rules -[Create Loyalty Earning Rule]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-earning-rule -[Update Loyalty Earning Rule]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-earning-rule -[Delete Loyalty Earning Rule]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-earning-rule - -[List Loyalty Members]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-members -[Add Loyalty Member]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-member -[Get Loyalty Member]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-member -[Add Loyalty Card Balance]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-loyalty-card-balance -[Redeem Loyalty Reward]:https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-loyalty-card diff --git a/Rakefile b/Rakefile index 6fdcf652..c72ca30d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,10 @@ -require 'bundler/gem_tasks' -require 'rspec/core/rake_task' +require "bundler/gem_tasks" -RSpec::Core::RakeTask.new(:spec) -task :default => :spec \ No newline at end of file +begin + require 'rspec/core/rake_task' + + RSpec::Core::RakeTask.new(:spec) + task default: :spec +rescue LoadError + # no rspec available +end diff --git a/VoucherifySdk.gemspec b/VoucherifySdk.gemspec new file mode 100644 index 00000000..4ef39318 --- /dev/null +++ b/VoucherifySdk.gemspec @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- + +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +$:.push File.expand_path("../lib", __FILE__) +require "VoucherifySdk/version" + +Gem::Specification.new do |s| + s.name = "voucherify" + s.version = VoucherifySdk::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ['pawelrychlik'] + s.email = ['pawel.rychlik@rspective.pl'] + + s.summary = %q{Ruby SDK for Voucherify. More info on http://www.voucherify.io} + s.homepage = 'https://github.com/voucherifyio/sdk-ruby-openapi-based' + s.license = 'MIT' + s.required_ruby_version = ">= 2.7" + + s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' + + s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } + s.test_files = `find __tests__/spec/*`.split("\n") + s.require_paths = ["lib"] +end diff --git a/__tests__/README.md b/__tests__/README.md new file mode 100644 index 00000000..1f1f81e7 --- /dev/null +++ b/__tests__/README.md @@ -0,0 +1,35 @@ +## Introductions + +This is the test suite for the Voucherify Ruby SDK, which is based on the OpenAPI specification. +Instead of relying on an automatically generated SDK tests, this test suite has been manually crafted. +The primary reason for this approach is to ensure that the most critical aspects of the SDK function flawlessly. + +## Running tests + +We strongly recommend running the tests using the Dockerfile provided in the root directory. +If you prefer to run tests locally, here are the steps you need to follow. + +### Requirements + +- all elements described in [main README.md](../README.md) like Ruby and Gem manager +- Voucherify SDK built locally +- rspec installed `(gem install rspec)` + +### Running locally + +1. Go into `root` directory +2. Follow the steps described in [main README.md](../README.md) for building SDK locally +3. Run `gem install rspec` command +4. Go into `__tests__` directory +5. Run `rspec ./spec` command + +**Note that running tests will affect your Voucherify project data. Run tests only on development projects.** + +## Contributing + +All new tests should be added to the `spec` directory. +This directory is intended exclusively for test suites and should contain minimal logic. +Place all advanced logic in the `lib` directory. It's important to maintain an appropriate division of modules and functions. +Keep any essential global logic in the `voucherify_data.rb` singleton. + +**Please note that in the current state of the test suite, some tests are interdependent. All tests run in alphanumeric order within the `spec` directory.** diff --git a/__tests__/lib/campaigns.rb b/__tests__/lib/campaigns.rb new file mode 100644 index 00000000..0fbba38c --- /dev/null +++ b/__tests__/lib/campaigns.rb @@ -0,0 +1,128 @@ +require_relative 'utils.rb' +require 'VoucherifySdk' +require 'json' + +def create_validation_rule_applicable_to(validation_rules_api_instance, product_id) + begin + created_validation_rule = validation_rules_api_instance.create_validation_rules({ + validation_rules_create_request_body: VoucherifySdk::ValidationRulesCreateRequestBody.new({ + name: generate_random_string(), + applicable_to: VoucherifySdk::ValidationRuleBaseApplicableTo.new({ + included: [VoucherifySdk::ApplicableTo.new({ + object: "product", + id: product_id + })] + }), + type:"basic", + }) + }) + + return created_validation_rule + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def create_validation_rule_more_than(validation_rules_api_instance, product_id) + begin + created_validation_rule = validation_rules_api_instance.create_validation_rules({ + validation_rules_create_request_body: VoucherifySdk::ValidationRulesCreateRequestBody.new({ + name: generate_random_string(), + rules: { + "1": { + name: "order.amount", + conditions: { + "$more_than": [500000] + }, + rules: {} + } + }, + type:"basic", + }) + }) + + return created_validation_rule + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def create_discount_campaign(campaigns_api_instance, validation_rule_id) + begin + campaign = campaigns_api_instance.create_campaign({ + campaigns_create_request_body: VoucherifySdk::CampaignsCreateDiscountCouponsCampaign.new({ + campaign_type: "DISCOUNT_COUPONS", + name: generate_random_string(), + type: "AUTO_UPDATE", + voucher: VoucherifySdk::DiscountCouponsCampaignVoucher.new({ + discount: VoucherifySdk::DiscountAmount.new({ + type: "AMOUNT", + amount_off: 1000 + }) + }), + validation_rules: [validation_rule_id] + }) + }) + + return campaign + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def create_promotion_campaign(campaigns_api_instance) + begin + + campaign = campaigns_api_instance.create_campaign({ + campaigns_create_request_body: { + campaign_type: "PROMOTION", + name: generate_random_string(), + promotion: { + tiers: [ + { + name: generate_random_string(), + banner: generate_random_string(), + action: { + discount: { + type: "AMOUNT", + amount_off: 1000 + } + } + } + ]} + } + }) + + return campaign + end +end + +def create_loyalty_campaign(campaigns_api_instance) + begin + campaign = campaigns_api_instance.create_campaign({ + campaigns_create_request_body: { + campaign_type: "LOYALTY_PROGRAM", + name: generate_random_string(), + voucher: { + type: "LOYALTY_CARD", + loyalty_card: { + points: 1000, + } + } + } + }) + end +end + +def delete_campaign(campaigns_api_instance, campaign_id) + begin + result = campaigns_api_instance.delete_campaign(campaign_id) + + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + + + diff --git a/__tests__/lib/config.rb b/__tests__/lib/config.rb new file mode 100644 index 00000000..51a9b016 --- /dev/null +++ b/__tests__/lib/config.rb @@ -0,0 +1,70 @@ +require 'time' +require 'VoucherifySdk' +require 'json/ext' +require 'dotenv' + +current_directory = File.dirname(__FILE__) +parent_directory = File.expand_path('../..', current_directory) +dotenv_path = File.join(parent_directory, '.env') + +Dotenv.load(dotenv_path) + +module Config + VoucherifySdk.configure do |config| + config.api_key['X-App-Id'] = ENV['X_APP_ID'] + config.api_key['X-App-Token'] = ENV['X_APP_TOKEN'] + config.host = ENV['VOUCHERIFY_HOST'] || 'https://api.voucherify.io' + end + + def self.products_api_instance + return VoucherifySdk::ProductsApi.new() + end + + def self.campaigns_api_instance + return VoucherifySdk::CampaignsApi.new() + end + + def self.validation_rules_api_instance + return VoucherifySdk::ValidationRulesApi.new() + end + + def self.customers_api_instance + return VoucherifySdk::CustomersApi.new() + end + + def self.exports_api_instance + return VoucherifySdk::ExportsApi.new() + end + + def self.redemptions_api_instance + return VoucherifySdk::RedemptionsApi.new() + end + + def self.publications_api_instance + return VoucherifySdk::PublicationsApi.new() + end + + def self.qualifications_api_instance + return VoucherifySdk::QualificationsApi.new() + end + + def self.validations_api_instance + return VoucherifySdk::ValidationsApi.new() + end + + def self.vouchers_api_instance + return VoucherifySdk::VouchersApi.new() + end + + def self.events_api_instance + return VoucherifySdk::EventsApi.new() + end + + def generate_random_string(length=10) + chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + random_string = Array.new(length) { chars.sample }.join + return random_string + end + +end + diff --git a/__tests__/lib/customers.rb b/__tests__/lib/customers.rb new file mode 100644 index 00000000..2638baff --- /dev/null +++ b/__tests__/lib/customers.rb @@ -0,0 +1,34 @@ +require_relative 'utils.rb' +require 'VoucherifySdk' + +def create_customer(customers_api_instance) + begin + # Create Customer + created_customer = customers_api_instance.create_customer({ + customers_create_request_body: VoucherifySdk::CustomersCreateRequestBody.new({ + source_id: generate_random_string(), + name: "John Doe", + address: VoucherifySdk::CustomerBaseAddress.new({ + country: "US", + city: "New York", + line_1: "5th Avenue", + line_2: "1/2", + postal_code: "11-111" + }) + }) + }) + return created_customer + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def delete_customer_permanently(customers_api_instance, customer_id) + begin + # Delete Customer + result = customers_api_instance.customer_permanently_deletion(customer_id) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end diff --git a/__tests__/lib/events.rb b/__tests__/lib/events.rb new file mode 100644 index 00000000..f7baabd9 --- /dev/null +++ b/__tests__/lib/events.rb @@ -0,0 +1,24 @@ +require_relative 'utils.rb' +require 'VoucherifySdk' + +def create_event(events_api_instance) + begin + events_create_request_body = VoucherifySdk::EventsCreateRequestBody.new({ + event: 'test-event', + customer: VoucherifySdk::Customer.new({ + source_id: 'test-customer' + }), + metadata: nil, + referral: nil, + loyalty: nil + }) + + created_event = events_api_instance.track_custom_event({ + events_create_request_body: events_create_request_body + }) + + return created_event + rescue VoucherifySdk::ApiError => e + return nil + end +end \ No newline at end of file diff --git a/__tests__/lib/products.rb b/__tests__/lib/products.rb new file mode 100644 index 00000000..4e8e5efa --- /dev/null +++ b/__tests__/lib/products.rb @@ -0,0 +1,116 @@ +require_relative 'utils.rb' +require 'VoucherifySdk' + +def create_product(products_api_instance, price) + begin + result = products_api_instance.create_product({ + products_create_request_body: VoucherifySdk::ProductsCreateRequestBody.new({ + source_id: generate_random_string(), + name: generate_random_string(), + price: price, + attributes: ["color", "memory", "processor"] + }) + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def delete_product(products_api_instance, product_id) + begin + result = products_api_instance.delete_product(product_id, { + force: true + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def update_product(products_api_instance, source_id) + begin + result = products_api_instance.update_product(source_id, { + products_update_request_body: VoucherifySdk::ProductsUpdateRequestBody.new({ + price: 55000 + }) + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def update_product_in_bulk(products_api_instance) + begin + result = products_api_instance.update_products_in_bulk({ + products_update_in_bulk_request_body: [ + VoucherifySdk::ProductsUpdateInBulkRequestBody.new({source_id: generate_random_string(), price: 1000}), + VoucherifySdk::ProductsUpdateInBulkRequestBody.new({source_id: generate_random_string(), price: 2000}), + ] + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def update_metadata_in_bulk(products_api_instance, source_ids) + begin + result = products_api_instance.update_products_metadata_in_bulk({ + products_metadata_update_in_bulk_request_body: VoucherifySdk::ProductsMetadataUpdateInBulkRequestBody.new({ + source_ids: source_ids, + metadata: { + "key1" => "value1", + "key2" => "value2" + } + }) + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def create_sku(products_api_instance, source_id, price) + begin + result = products_api_instance.create_sku(source_id, { + products_skus_create_request_body: VoucherifySdk::ProductsSkusCreateRequestBody.new({ + source_id: generate_random_string(), + price: price, + attributes: { + "color": "red", + "memory": "16GB", + "processor": "Intel Core i7" + } + }) + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def update_sku(products_api_instance, source_id, sku_id, price) + begin + result = products_api_instance.update_sku(source_id, sku_id, { + products_skus_update_request_body: VoucherifySdk::ProductsSkusUpdateRequestBody.new({ + price: price + }) + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end + +def delete_sku(products_api_instance, source_id, sku_id) + begin + result = products_api_instance.delete_sku(source_id, sku_id, { + force: true + }) + return result + rescue VoucherifySdk::ApiError => e + return nil + end +end diff --git a/__tests__/lib/stackables.rb b/__tests__/lib/stackables.rb new file mode 100644 index 00000000..2cabdebb --- /dev/null +++ b/__tests__/lib/stackables.rb @@ -0,0 +1,59 @@ +def create_request_body_redeemable(voucher_id) + begin + validations_validate_request_body_redeemables = [ + VoucherifySdk::RedeemVoucher.new({ + object: "voucher", id: voucher_id + }) + ] + return validations_validate_request_body_redeemables + end +end + + +def validate_stacked_discounts(validations_api_instance, voucher_id, product_id, customer, amount) + begin + result = validations_api_instance.validate_stacked_discounts({ + validations_validate_request_body: VoucherifySdk::ValidationsValidateRequestBody.new({ + redeemables: create_request_body_redeemable(voucher_id), + order: { + items: [{ + related_object: "product", + quantity: 1, + discount_quantity: 1, + amount: amount, + price: amount, + product_id: product_id, + product: { + id: product_id + } + }], + amount: amount, + customer: { + id: customer.id + } + }, + customer: { + source_id: customer.source_id + } + }) + }) + return result; + rescue VoucherifySdk::ApiError => e + puts(e) + return nil; + end +end + +def redeem_stacked_discounts(redemptions_api_instance, voucher_id) + begin + result = redemptions_api_instance.redeem_stacked_discounts({ + redemptions_redeem_request_body: VoucherifySdk::RedemptionsRedeemRequestBody.new({ + redeemables: create_request_body_redeemable(voucher_id), + order: VoucherifySdk::Order.new(amount: 20000) + }) + }) + return result; + rescue VoucherifySdk::ApiError => e + return nil; + end +end diff --git a/__tests__/lib/utils.rb b/__tests__/lib/utils.rb new file mode 100644 index 00000000..3c4bc49c --- /dev/null +++ b/__tests__/lib/utils.rb @@ -0,0 +1,5 @@ +def generate_random_string(length=10) + chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + random_string = Array.new(length) { chars.sample }.join + return random_string +end diff --git a/__tests__/lib/voucherify_data.rb b/__tests__/lib/voucherify_data.rb new file mode 100644 index 00000000..90e640d8 --- /dev/null +++ b/__tests__/lib/voucherify_data.rb @@ -0,0 +1,95 @@ +require 'singleton' + +class VoucherifyData + include Singleton + + attr_accessor :product, :customer + + def initialize + @product = nil + @customer = nil + @discount_campaign = nil + @loyalty_campaign = nil + @voucher = nil + @voucher_with_more_than_validation_rule = nil + @loyalty_card = nil + @product_ids = [] + @sku = nil + end + + def set_discount_campaign(discount_campaign) + @discount_campaign = discount_campaign + end + + def get_discount_campaign + return @discount_campaign + end + + def set_product(product) + @product = product + end + + def set_customer(customer) + @customer = customer + end + + def add_product_id(product_id) + @product_ids.push(product_id) + end + + def get_product_ids + @product_ids + end + + def get_voucher_with_more_than_validation_rule + @voucher_with_more_than_validation_rule + end + + def set_voucher_with_more_than_validation_rule(voucher) + @voucher_with_more_than_validation_rule = voucher + end + + def set_sku(sku) + @sku = sku + end + + def get_sku + @sku + end + + def set_voucher(voucher) + @voucher = voucher + end + + def get_product + @product + end + + def get_customer + @customer + end + + def get_discount_campaign + @discount_campaign + end + + def get_voucher + @voucher + end + + def get_loyalty_campaign + @loyalty_campaign + end + + def set_loyalty_campaign(loyalty_campaign) + @loyalty_campaign = loyalty_campaign + end + + def get_loyalty_card + @loyalty_card + end + + def set_loyalty_card(loyalty_card) + @loyalty_card = loyalty_card + end +end diff --git a/__tests__/spec/1_products_spec.rb b/__tests__/spec/1_products_spec.rb new file mode 100644 index 00000000..7290ba60 --- /dev/null +++ b/__tests__/spec/1_products_spec.rb @@ -0,0 +1,101 @@ +require_relative '../lib/products.rb' +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' + +RSpec.describe 'Products API', :order => :defined do + before(:each) do + @products_api_instance = Config.products_api_instance() + @voucherify_data = VoucherifyData.instance() + + end + + it 'creates a product with price 20000 and price 60000', :order => :first do + created_product = create_product(@products_api_instance, 20000) + expect(created_product).not_to be_nil + + @voucherify_data.set_product(created_product) + @voucherify_data.add_product_id(created_product.source_id) + + created_product_2 = create_product(@products_api_instance, 60000) + expect(created_product_2).not_to be_nil + + @voucherify_data.add_product_id(created_product_2.source_id) + end + + it 'get product previously created', :order => :second do + product = @products_api_instance.get_product(@voucherify_data.get_product().source_id) + + expect(product).not_to be_nil + expect(product.price).to eq(20000) + end + + it 'update price of created product to 55000 using source_id for founding product', :order => :third do + updated_product = update_product(@products_api_instance, @voucherify_data.get_product().source_id) + + expect(updated_product).not_to be_nil + expect(updated_product.price).to eq(55000) + end + + it 'list products', :order => :fourth do + products = @products_api_instance.list_products() + + expect(products).not_to be_nil + expect(products.products.size).to be > 0 + end + + it 'update products in bulk', :order => :fifth do + async_action = update_product_in_bulk(@products_api_instance) + + expect(async_action).not_to be_nil + end + + it 'update metadata in bulk', :order => :sixth do + async_action = update_metadata_in_bulk(@products_api_instance, @voucherify_data.get_product_ids()) + + expect(async_action).not_to be_nil + end + + it 'add sku to product with price 5000', :order => :seventh do + sku = create_sku(@products_api_instance, @voucherify_data.get_product().source_id, 5000) + + expect(sku).not_to be_nil + expect(sku.source_id).not_to be_nil + expect(sku.price).to eq(5000) + + @voucherify_data.set_sku(sku) + end + + it 'update sku should have price equals 2000', :order => :eighth do + sku = update_sku(@products_api_instance, @voucherify_data.get_product().source_id, @voucherify_data.get_sku().source_id, 2000) + + expect(sku).not_to be_nil + expect(sku.source_id).not_to be_nil + expect(sku.price).to eq(2000) + end + + it 'get sku', :order => :ninth do + sku = @products_api_instance.get_sku(@voucherify_data.get_sku().source_id) + + expect(sku).not_to be_nil + end + + it 'list skus in product', :order => :tenth do + skus = @products_api_instance.list_skus_in_product(@voucherify_data.get_product().source_id) + + expect(skus).not_to be_nil + expect(skus.skus.size).to be > 0 + end + + #REMOVE ELEMENTS + it 'remove product', :order => :eleventh do + deleted_product = delete_product(@products_api_instance, @voucherify_data.get_product().source_id) + + expect(deleted_product).to be_nil + end + + it 'remove sku', :order => :twelweth do + deleted_sku = delete_sku(@products_api_instance, @voucherify_data.get_product().source_id, @voucherify_data.get_sku().source_id) + + expect(deleted_sku).to be_nil + end +end diff --git a/__tests__/spec/2_campaigns_spec.rb b/__tests__/spec/2_campaigns_spec.rb new file mode 100644 index 00000000..4cc5dd10 --- /dev/null +++ b/__tests__/spec/2_campaigns_spec.rb @@ -0,0 +1,95 @@ +require_relative '../lib/campaigns.rb' +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' + +RSpec.describe 'Campaigns API', :order => :defined do + before(:each) do + @campaigns_api_instance = Config.campaigns_api_instance() + @validation_rules_api_instance = Config.validation_rules_api_instance() + @voucherify_data = VoucherifyData.instance() + end + + $created_validation_rule = nil + $created_discount_campaign = nil + $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 + end + + it 'create a discount campaign with applicable_to validation rule', :order => :second do + created_discount_campaign = create_discount_campaign(@campaigns_api_instance, $created_validation_rule_applicable_to.id) + + expect(created_discount_campaign).not_to be_nil + + $created_discount_campaign = created_discount_campaign + @voucherify_data.set_discount_campaign(created_discount_campaign) + end + + it 'create a promotion campaign', :order => :thrid do + created_promotion_campaign = create_promotion_campaign(@campaigns_api_instance) + + expect(created_promotion_campaign).not_to be_nil + + $created_promotion_campaign = created_promotion_campaign + end + + it 'create a loyalty campaign', :order => :fourth do + created_loyalty_campaign = create_loyalty_campaign(@campaigns_api_instance) + + expect(created_loyalty_campaign).not_to be_nil + + $created_loyalty_campaign = created_loyalty_campaign + @voucherify_data.set_loyalty_campaign(created_loyalty_campaign) + end + + it 'delete the promotion campaign', :order => :fifth do + deleted_promotion_campaign = delete_campaign(@campaigns_api_instance, $created_promotion_campaign.id) + + expect(deleted_promotion_campaign).not_to be_nil + end + + it 'create a voucher', :order => :sixth do + created_voucher = @campaigns_api_instance.add_vouchers_to_campaign($created_discount_campaign.id, { + vouchers_count: 1, + }) + @voucherify_data.set_voucher(created_voucher) + expect(created_voucher).not_to be_nil + end + + it 'create a bundle of vouchers', :order => :seventh do + async_action = @campaigns_api_instance.add_vouchers_to_campaign($created_discount_campaign.id, { + vouchers_count: 5, + }) + expect(async_action).not_to be_nil + end + + it 'create a loyalty card', :order => :eighth do + created_loyalty_card = @campaigns_api_instance.add_vouchers_to_campaign($created_loyalty_campaign.id, { + vouchers_count: 1, + }) + @voucherify_data.set_loyalty_card(created_loyalty_card) + expect(created_loyalty_card).not_to be_nil + end + + it 'create a campaign with validation rule and add voucher', :order => :ninth do + validation_rule = create_validation_rule_more_than(@validation_rules_api_instance, @voucherify_data.get_product.id) + expect(validation_rule).not_to be_nil + + campaign = create_discount_campaign(@campaigns_api_instance, validation_rule.id) + expect(campaign).not_to be_nil + + voucher = @campaigns_api_instance.add_vouchers_to_campaign(campaign.id, { + vouchers_count: 1, + }) + + @voucherify_data.set_voucher_with_more_than_validation_rule(voucher) + end +end diff --git a/__tests__/spec/3_customers_spec.rb b/__tests__/spec/3_customers_spec.rb new file mode 100644 index 00000000..73d972ed --- /dev/null +++ b/__tests__/spec/3_customers_spec.rb @@ -0,0 +1,24 @@ +require_relative '../lib/customers.rb' +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' + +RSpec.describe 'Customers API', :order => :defined do + before(:each) do + @customers_api_instance = Config.customers_api_instance() + @voucherify_data = VoucherifyData.instance() + end + + it 'create a customer', :order => :first do + created_customer = create_customer(@customers_api_instance) + expect(created_customer).not_to be_nil + @voucherify_data.set_customer(created_customer) + end + + it 'create a customer and delete it', :order => :second do + created_customer = create_customer(@customers_api_instance) + expect(created_customer).not_to be_nil + + result = delete_customer_permanently(@customers_api_instance, created_customer.id) + expect(created_customer).not_to be_nil + end +end diff --git a/__tests__/spec/4_publications_spec.rb b/__tests__/spec/4_publications_spec.rb new file mode 100644 index 00000000..89ea6ca1 --- /dev/null +++ b/__tests__/spec/4_publications_spec.rb @@ -0,0 +1,23 @@ +require_relative '../lib/config.rb' + +RSpec.describe 'Publications API', :order => :defined do + before(:each) do + @publications_api_instance = Config.publications_api_instance() + @voucherify_data = VoucherifyData.instance() + end + + it 'create a publication', :order => :first do + publication = @publications_api_instance.create_publication({ + join_once: true, + publications_create_request_body: VoucherifySdk::CreatePublicationWithCampaign.new({ + customer: VoucherifySdk::Customer.new({ + id: @voucherify_data.get_customer().id + }), + campaign: VoucherifySdk::CreatePublicationCampaign.new({ + name: @voucherify_data.get_discount_campaign().name + }) + }) + }) + expect(publication).not_to be_nil + end +end diff --git a/__tests__/spec/5_qualifications_spec.rb b/__tests__/spec/5_qualifications_spec.rb new file mode 100644 index 00000000..64846cc6 --- /dev/null +++ b/__tests__/spec/5_qualifications_spec.rb @@ -0,0 +1,27 @@ +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' + +RSpec.describe 'Qualifications API', :order => :defined do + before(:each) do + @qualifications_api_instance = Config.qualifications_api_instance() + @voucherify_data = VoucherifyData.instance() + end + + it 'check eligibility', :order => :first do + result = @qualifications_api_instance.check_eligibility({ + qualifications_check_eligibility_request_body: VoucherifySdk::QualificationsCheckEligibilityRequestBody.new({ + customer: VoucherifySdk::Customer.new({ + id: @voucherify_data.get_customer().id + }), + order: VoucherifySdk::Order.new({ + amount: 20000, + }), + options: VoucherifySdk::QualificationsOption.new({ + limit: 100 + }) + }) + }) + + expect(result).not_to be_nil + end +end \ No newline at end of file diff --git a/__tests__/spec/6_validations_spec.rb b/__tests__/spec/6_validations_spec.rb new file mode 100644 index 00000000..c51d9f07 --- /dev/null +++ b/__tests__/spec/6_validations_spec.rb @@ -0,0 +1,126 @@ +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' +require_relative '../lib/stackables.rb' + +RSpec.describe 'Validations API', :order => :defined do + before(:each) do + @validations_api_instance = Config.validations_api_instance() + @voucherify_data = VoucherifyData.instance() + end + + $validation_result_successful = nil + $order_amount_successful = 20000 + + $validation_result_failed = nil + $order_amount_failed = 1000 + + it 'validate stacked discounts (successful)', :order => :first do + $validation_result_successful = validate_stacked_discounts( + @validations_api_instance, + @voucherify_data.get_voucher().code, + @voucherify_data.get_product.id, + @voucherify_data.get_customer(), + $order_amount_successful + ) + + expect($validation_result_successful).not_to be_nil + expect($validation_result_successful.valid).to be(true) + end + + it 'validates presence of the redeemables array (successful)', :order => :second do + expect($validation_result_successful.redeemables).not_to be_nil + expect($validation_result_successful.redeemables).to be_an(Array) + end + + it 'checks if redeemables items have necessary keys (successful)', :order => :third do + redeemable = $validation_result_successful.redeemables.first + + expect(redeemable.status).to eq("APPLICABLE") + expect(redeemable.id).not_to be_nil + expect(redeemable.object).to eq("voucher") + expect(redeemable.order).to be_a(VoucherifySdk::OrderCalculated) + expect(redeemable.applicable_to).to be_a(VoucherifySdk::ApplicableToResultList) + expect(redeemable.inapplicable_to).to be_a(VoucherifySdk::InapplicableToResultList) + expect(redeemable.result).to be_a(VoucherifySdk::RedeemableResultPromotionTier) + end + + it 'validates the order object structure (successful)', :order => :fourth do + order = $validation_result_successful.order + + expect(order).not_to be_nil + expect(order.amount).to eq($order_amount_successful) + expect(order.total_amount).to eq($order_amount_successful - @voucherify_data.get_discount_campaign().voucher.discount.amount_off) + end + + it 'validates details of the discount in the first redeemable (successful)', :order => :fifth do + discount = $validation_result_successful.redeemables.first.result.discount + + expect(discount.type).to eq("AMOUNT") + expect(discount.amount_off).to eq(@voucherify_data.get_discount_campaign().voucher.discount.amount_off) + end + + it 'checks is redeemables applicable_to points on product (successful)', :order => :sixth do + redeemable = $validation_result_successful.redeemables.first + applicable_to = redeemable.applicable_to + + expect(applicable_to.data).not_to be_nil + expect(applicable_to.data).to be_a(Array) + + applicable_to_first = applicable_to.data.first + expect(applicable_to_first).not_to be_nil + expect(applicable_to_first.object).to eq("product") + expect(applicable_to_first.id).to eq(@voucherify_data.get_product().id) + end + + it 'checks validation customer response is valid (successful)', :order => :seventh do + expect($validation_result_successful.tracking_id).to_not be_nil + expect($validation_result_successful.order.customer).to_not be_nil + expect($validation_result_successful.order.customer).to be_a(VoucherifySdk::CustomerId) + expect($validation_result_successful.order.customer.id).to eq(@voucherify_data.get_customer().id) + expect($validation_result_successful.order.customer.object).to eq("customer") + end + + ######### + ######### + ######### + + it 'validate stacked discounts (failed)', :order => :eighth do + $validation_result_failed = validate_stacked_discounts( + @validations_api_instance, + @voucherify_data.get_voucher_with_more_than_validation_rule().code, + @voucherify_data.get_product.id, + @voucherify_data.get_customer(), + $order_amount_failed + ) + + expect($validation_result_failed).not_to be_nil + expect($validation_result_failed.valid).to be(false) + end + + it 'validates presence of the redeemables and inapplicable_redeemables (failed)', :order => :ninth do + expect($validation_result_failed.redeemables).not_to be_nil + expect($validation_result_failed.redeemables).to be_an(Array) + + expect($validation_result_failed.inapplicable_redeemables).not_to be_nil + expect($validation_result_failed.inapplicable_redeemables).to be_an(Array) + end + + it 'checks if redeemables items have necessary keys (failed)', :order => :tenth do + inapplicable_redeemables = $validation_result_failed.inapplicable_redeemables.first + + expect(inapplicable_redeemables.status).to eq("INAPPLICABLE") + expect(inapplicable_redeemables.id).to eq(@voucherify_data.get_voucher_with_more_than_validation_rule().code) + expect(inapplicable_redeemables.object).to eq("voucher") + + expect(inapplicable_redeemables.result).not_to be_nil + expect(inapplicable_redeemables.result).to be_a(VoucherifySdk::ValidationsRedeemableInapplicableResult) + + expect(inapplicable_redeemables.result.error).not_to be_nil + expect(inapplicable_redeemables.result.error).to be_an(VoucherifySdk::Error) + end + + it 'checks validation customer response is valid (failed)', :order => :eleventh do + expect($validation_result_failed.tracking_id).to_not be_nil + end + +end diff --git a/__tests__/spec/7_vouchers_spec.rb b/__tests__/spec/7_vouchers_spec.rb new file mode 100644 index 00000000..ee72c04d --- /dev/null +++ b/__tests__/spec/7_vouchers_spec.rb @@ -0,0 +1,40 @@ +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' +require 'VoucherifySdk' + +RSpec.describe 'Campaigns API', :order => :defined do + before(:each) do + @vouchers_api_instance = Config.vouchers_api_instance() + @voucherify_data = VoucherifyData.instance() + end + + it 'get voucher previously created', :order => :first do + voucher = @vouchers_api_instance.get_voucher(@voucherify_data.get_voucher().code) + + expect(voucher).not_to be_nil + end + + it 'disable voucher previously created', :order => :second do + voucher = @vouchers_api_instance.disable_voucher(@voucherify_data.get_voucher().code) + + expect(voucher).not_to be_nil + end + + it 'enable voucher previously created', :order => :thrird do + voucher = @vouchers_api_instance.enable_voucher(@voucherify_data.get_voucher().code) + + expect(voucher).not_to be_nil + end + + it 'update loyalty card balance', :order => :fourth do + vouchers_balance_update_request_body = VoucherifySdk::VouchersBalanceUpdateRequestBody.new({ + source_id: generate_random_string(), + amount: 10000, + reason: "Regular customer" + }) + + response = @vouchers_api_instance.update_voucher_balance(@voucherify_data.get_loyalty_card().code, vouchers_balance_update_request_body) + + expect(response).not_to be_nil + end +end \ No newline at end of file diff --git a/__tests__/spec/8_events_spec.rb b/__tests__/spec/8_events_spec.rb new file mode 100644 index 00000000..dfdb735d --- /dev/null +++ b/__tests__/spec/8_events_spec.rb @@ -0,0 +1,16 @@ +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' +require_relative '../lib/events.rb' + +RSpec.describe 'Campaigns API', :order => :defined do + before(:each) do + @events_api_instance = Config.events_api_instance() + @voucherify_data = VoucherifyData.instance() + end + + it 'track custom event', :order => :first do + created_event = create_event(@events_api_instance) + + expect(created_event).not_to be_nil + end +end \ No newline at end of file diff --git a/__tests__/spec/9_redemptions_spec.rb b/__tests__/spec/9_redemptions_spec.rb new file mode 100644 index 00000000..5fd8fed6 --- /dev/null +++ b/__tests__/spec/9_redemptions_spec.rb @@ -0,0 +1,14 @@ +require_relative '../lib/config.rb' +require_relative '../lib/voucherify_data.rb' +require_relative '../lib/stackables.rb' + +RSpec.describe 'Redemptions API', :order => :defined do + before(:each) do + @redemptions_api_instance = Config.redemptions_api_instance() + @voucherify_data = VoucherifyData.instance() + end + it 'redeem stacked discounts', :order => :second do + result = redeem_stacked_discounts(@redemptions_api_instance, @voucherify_data.get_voucher().code) + expect(result).not_to be_nil + end +end \ No newline at end of file diff --git a/bin/console b/bin/console deleted file mode 100755 index 74f2557f..00000000 --- a/bin/console +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env ruby - -require "bundler/setup" -require "voucherify" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start diff --git a/bin/setup b/bin/setup deleted file mode 100755 index dce67d86..00000000 --- a/bin/setup +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle install - -# Do any other automated setup that you need to do here diff --git a/docs/Any.md b/docs/Any.md new file mode 100644 index 00000000..65630718 --- /dev/null +++ b/docs/Any.md @@ -0,0 +1,53 @@ +# VoucherifySdk::Any + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::Any.openapi_one_of +# => +# [ +# :'Array', +# :'Float', +# :'Object', +# :'String' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::Any.build(data) +# => #:0x00007fdd4aab02a0> + +VoucherifySdk::Any.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `Array` +- `Float` +- `Object` +- `String` +- `nil` (if no type matches) + diff --git a/docs/ApplicableTo.md b/docs/ApplicableTo.md new file mode 100644 index 00000000..a78c0118 --- /dev/null +++ b/docs/ApplicableTo.md @@ -0,0 +1,21 @@ +# VoucherifySdk::ApplicableTo + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | This object stores information about the product collection. | | +| **id** | **String** | Unique product collection ID assigned by Voucherify. | | +| **source_id** | **String** | The source ID from your inventory system. | [optional] | +| **product_id** | **String** | Parent product's unique ID assigned by Voucherify. | [optional] | +| **product_source_id** | **String** | Parent product's source ID from your inventory system. | [optional] | +| **strict** | **Boolean** | | | +| **price** | **Float** | New fixed price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 price is written as 1000. In case of the fixed price being calculated by the formula, i.e. the price_formula parameter is present in the fixed price definition, this value becomes the fallback value. Such that in a case where the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed price. | [optional] | +| **price_formula** | **Float** | Formula used to calculate the discounted price of an item. | [optional] | +| **effect** | [**ApplicableToEffect**](ApplicableToEffect.md) | | | +| **quantity_limit** | **Integer** | The maximum number of units allowed to be discounted per order line item. | [optional] | +| **aggregated_quantity_limit** | **Integer** | The maximum number of units allowed to be discounted combined across all matched order line items. | [optional] | +| **amount_limit** | **Integer** | Upper limit allowed to be applied as a discount per order line item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600. | [optional] | +| **aggregated_amount_limit** | **Integer** | Maximum discount amount per order. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount on the entire order is written as 600. This value is definable for the following discount effects: - `APPLY_TO_ITEMS` (each item subtotal is discounted equally) - `APPLY_TO_ITEMS_BY_QUANTITY` (each unit of matched products has the same discount value) | [optional] | +| **order_item_indices** | **Array<Integer>** | | [optional] | + diff --git a/docs/ApplicableToEffect.md b/docs/ApplicableToEffect.md new file mode 100644 index 00000000..a67c27e1 --- /dev/null +++ b/docs/ApplicableToEffect.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ApplicableToEffect + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ApplicableToResultList.md b/docs/ApplicableToResultList.md new file mode 100644 index 00000000..b56cefbf --- /dev/null +++ b/docs/ApplicableToResultList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ApplicableToResultList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **data** | [**Array<ApplicableTo>**](ApplicableTo.md) | Contains array of items to which the discount can apply. | | +| **total** | **Integer** | Total number of objects defining included products, SKUs, or product collections. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'list'] | +| **data_ref** | **String** | The type of object represented by JSON. | [default to 'data'] | + diff --git a/docs/ArrayInner.md b/docs/ArrayInner.md new file mode 100644 index 00000000..8d883f4c --- /dev/null +++ b/docs/ArrayInner.md @@ -0,0 +1,51 @@ +# VoucherifySdk::ArrayInner + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ArrayInner.openapi_one_of +# => +# [ +# :'Float', +# :'Object', +# :'String' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ArrayInner.build(data) +# => # + +VoucherifySdk::ArrayInner.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `Float` +- `Object` +- `String` +- `nil` (if no type matches) + diff --git a/docs/AsyncActions.md b/docs/AsyncActions.md new file mode 100644 index 00000000..305d4c44 --- /dev/null +++ b/docs/AsyncActions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::AsyncActions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/BusValRuleAssignment.md b/docs/BusValRuleAssignment.md new file mode 100644 index 00000000..f8a6a93b --- /dev/null +++ b/docs/BusValRuleAssignment.md @@ -0,0 +1,16 @@ +# VoucherifySdk::BusValRuleAssignment + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The unique identifier for a assignment | | +| **rule_id** | **String** | The unique identifier for a rule | | +| **related_object_id** | **String** | The unique identifier for a related object | | +| **related_object_type** | **String** | The type of related object | | +| **created_at** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the object was last updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'validation_rules_assignment'] | +| **validation_status** | **String** | The validation status of the assignment | [optional] | +| **validation_omitted_rules** | **Array<String>** | The list of omitted rules | [optional] | + diff --git a/docs/Campaign.md b/docs/Campaign.md new file mode 100644 index 00000000..5e792342 --- /dev/null +++ b/docs/Campaign.md @@ -0,0 +1,37 @@ +# VoucherifySdk::Campaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **name** | **String** | Campaign name. | | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **campaign_type** | **String** | Type of campaign. | | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published | | +| **voucher** | [**CampaignVoucher**](CampaignVoucher.md) | | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **active** | **Boolean** | A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the campaign was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was updated in ISO 8601 format. | [optional] | +| **category** | **String** | Unique category name. | [optional] | +| **creation_status** | **String** | Indicates the status of the campaign creation. | | +| **vouchers_generation_status** | **String** | Indicates the status of the campaign's vouchers. | | +| **protected** | **Boolean** | Indicates whether the resource can be deleted. | | +| **category_id** | **String** | Unique category ID that this campaign belongs to. | | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the campaign. | [default to 'campaign'] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | +| **loyalty_tiers_expiration** | [**LoyaltyTiersExpirationAll**](LoyaltyTiersExpirationAll.md) | | [optional] | +| **promotion** | [**PromotionTiersList**](PromotionTiersList.md) | | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | + diff --git a/docs/CampaignBase.md b/docs/CampaignBase.md new file mode 100644 index 00000000..fe81e5e9 --- /dev/null +++ b/docs/CampaignBase.md @@ -0,0 +1,35 @@ +# VoucherifySdk::CampaignBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **name** | **String** | Campaign name. | | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **campaign_type** | **String** | Type of campaign. | | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published | | +| **voucher** | [**CampaignVoucher**](CampaignVoucher.md) | | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **active** | **Boolean** | A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the campaign was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was updated in ISO 8601 format. | [optional] | +| **category** | **String** | Unique category name. | [optional] | +| **creation_status** | **String** | Indicates the status of the campaign creation. | | +| **vouchers_generation_status** | **String** | Indicates the status of the campaign's vouchers. | | +| **protected** | **Boolean** | Indicates whether the resource can be deleted. | | +| **category_id** | **String** | Unique category ID that this campaign belongs to. | | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the campaign. | [default to 'campaign'] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | +| **loyalty_tiers_expiration** | [**LoyaltyTiersExpirationAll**](LoyaltyTiersExpirationAll.md) | | [optional] | + diff --git a/docs/CampaignBaseValidityTimeframe.md b/docs/CampaignBaseValidityTimeframe.md new file mode 100644 index 00000000..b4751f6e --- /dev/null +++ b/docs/CampaignBaseValidityTimeframe.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CampaignBaseValidityTimeframe + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **interval** | **String** | Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a campaign with an `interval` of `P2D` will be active every other day. | [optional] | +| **duration** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format. For example, a campaign with a `duration` of `P1D` will be valid for a duration of one day. | [optional] | + diff --git a/docs/CampaignLoyaltyCard.md b/docs/CampaignLoyaltyCard.md new file mode 100644 index 00000000..a3df9e42 --- /dev/null +++ b/docs/CampaignLoyaltyCard.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CampaignLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | The initial number of points to assign to the loyalty card. This is the current loyalty card score i.e. the number of loyalty points on the card. | | +| **expiration_rules** | [**CampaignLoyaltyCardExpirationRules**](CampaignLoyaltyCardExpirationRules.md) | | [optional] | + diff --git a/docs/CampaignLoyaltyCardExpirationRules.md b/docs/CampaignLoyaltyCardExpirationRules.md new file mode 100644 index 00000000..817abb8e --- /dev/null +++ b/docs/CampaignLoyaltyCardExpirationRules.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CampaignLoyaltyCardExpirationRules + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **period_type** | **String** | Type of period | | +| **period_value** | **Integer** | Value of the period | | +| **rounding_type** | **String** | Type of rounding | | +| **rounding_value** | **Integer** | Value of rounding | | + diff --git a/docs/CampaignLoyaltyVoucher.md b/docs/CampaignLoyaltyVoucher.md new file mode 100644 index 00000000..424d6298 --- /dev/null +++ b/docs/CampaignLoyaltyVoucher.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CampaignLoyaltyVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of voucher. | [default to 'LOYALTY_CARD'] | +| **loyalty_card** | [**CampaignLoyaltyCard**](CampaignLoyaltyCard.md) | | | +| **redemption** | [**CampaignLoyaltyVoucherRedemption**](CampaignLoyaltyVoucherRedemption.md) | | [optional] | +| **code_config** | [**CodeConfig**](CodeConfig.md) | | [optional] | + diff --git a/docs/CampaignLoyaltyVoucherRedemption.md b/docs/CampaignLoyaltyVoucherRedemption.md new file mode 100644 index 00000000..b5731b96 --- /dev/null +++ b/docs/CampaignLoyaltyVoucherRedemption.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignLoyaltyVoucherRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **quantity** | **Integer** | How many times a voucher can be redeemed. A `null` value means unlimited. | [optional] | + diff --git a/docs/CampaignVoucher.md b/docs/CampaignVoucher.md new file mode 100644 index 00000000..10bd2542 --- /dev/null +++ b/docs/CampaignVoucher.md @@ -0,0 +1,17 @@ +# VoucherifySdk::CampaignVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of voucher. | [default to 'DISCOUNT_VOUCHER'] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**Gift**](Gift.md) | | [optional] | +| **loyalty_card** | [**CampaignLoyaltyCard**](CampaignLoyaltyCard.md) | | [optional] | +| **redemption** | [**CampaignVoucherRedemption**](CampaignVoucherRedemption.md) | | | +| **code_config** | [**CodeConfigRequiredLengthCharsetPattern**](CodeConfigRequiredLengthCharsetPattern.md) | | | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | + diff --git a/docs/CampaignVoucherRedemption.md b/docs/CampaignVoucherRedemption.md new file mode 100644 index 00000000..01ee10d8 --- /dev/null +++ b/docs/CampaignVoucherRedemption.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignVoucherRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **quantity** | **Integer** | How many times a voucher can be redeemed. A `null` value means unlimited. | | + diff --git a/docs/CampaignsApi.md b/docs/CampaignsApi.md new file mode 100644 index 00000000..5a5c01b9 --- /dev/null +++ b/docs/CampaignsApi.md @@ -0,0 +1,694 @@ +# VoucherifySdk::CampaignsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**add_voucher_with_specific_code_to_campaign**](CampaignsApi.md#add_voucher_with_specific_code_to_campaign) | **POST** /v1/campaigns/{campaignId}/vouchers/{code} | Add Voucher with Specific Code to Campaign | +| [**add_vouchers_to_campaign**](CampaignsApi.md#add_vouchers_to_campaign) | **POST** /v1/campaigns/{campaignId}/vouchers | Add Vouchers to Campaign | +| [**create_campaign**](CampaignsApi.md#create_campaign) | **POST** /v1/campaigns | Create Campaign | +| [**delete_campaign**](CampaignsApi.md#delete_campaign) | **DELETE** /v1/campaigns/{campaignId} | Delete Campaign | +| [**disable_campaign**](CampaignsApi.md#disable_campaign) | **POST** /v1/campaigns/{campaignId}/disable | Disable Campaign | +| [**enable_campaign**](CampaignsApi.md#enable_campaign) | **POST** /v1/campaigns/{campaignId}/enable | Enable Campaign | +| [**get_campaign**](CampaignsApi.md#get_campaign) | **GET** /v1/campaigns/{campaignId} | Get Campaign | +| [**import_vouchers_to_campaign**](CampaignsApi.md#import_vouchers_to_campaign) | **POST** /v1/campaigns/{campaignId}/import | Import Vouchers to Campaign | +| [**import_vouchers_to_campaign_using_csv**](CampaignsApi.md#import_vouchers_to_campaign_using_csv) | **POST** /v1/campaigns/{campaignId}/importCSV | Import Vouchers to Campaign by CSV | +| [**list_campaigns**](CampaignsApi.md#list_campaigns) | **GET** /v1/campaigns | List Campaigns | +| [**update_campaign**](CampaignsApi.md#update_campaign) | **PUT** /v1/campaigns/{campaignId} | Update Campaign | + + +## add_voucher_with_specific_code_to_campaign + +> add_voucher_with_specific_code_to_campaign(campaign_id, code, opts) + +Add Voucher with Specific Code to Campaign + +This method gives a possibility to add a new voucher to an existing campaign. The voucher definition will be inherited from the definition kept in the campaign profile. However, you are able to overwrite a few properties inherited from the campaign. + +### 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::CampaignsApi.new +campaign_id = 'ABC' # String | The campaign ID or name of the campaign to which voucher will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. +code = 'code_example' # String | A custom **code** that identifies the voucher. +opts = { + campaigns_vouchers_create_request_body: VoucherifySdk::CampaignsVouchersCreateRequestBody.new # CampaignsVouchersCreateRequestBody | Specify the voucher parameters that you would like to overwrite. +} + +begin + # Add Voucher with Specific Code to Campaign + result = api_instance.add_voucher_with_specific_code_to_campaign(campaign_id, code, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->add_voucher_with_specific_code_to_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the campaign to which voucher will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. | | +| **code** | **String** | A custom **code** that identifies the voucher. | | +| **campaigns_vouchers_create_request_body** | [**CampaignsVouchersCreateRequestBody**](CampaignsVouchersCreateRequestBody.md) | Specify the voucher parameters that you would like to overwrite. | [optional] | + +### Return type + +[**CampaignsVouchersCreateResponseBody**](CampaignsVouchersCreateResponseBody.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 + + +## add_vouchers_to_campaign + +> add_vouchers_to_campaign(campaign_id, opts) + +Add Vouchers to Campaign + +This method gives the possibility to push new vouchers to an existing campaign. New vouchers will inherit properties from the campaign profile. However, it is possible to overwrite some of them in the request body. If you provide an optional code_config parameter with a voucher code configuration, then it will be used to generate new voucher codes. Otherwise, the voucher code configuration from the campaign will be used. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the campaign to which voucher(s) will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. +opts = { + vouchers_count: 56, # Integer | Number of vouchers that should be added. + campaigns_vouchers_create_in_bulk_request_body: VoucherifySdk::CampaignsVouchersCreateInBulkRequestBody.new # CampaignsVouchersCreateInBulkRequestBody | Specify the voucher parameters that you would like to overwrite. +} + +begin + # Add Vouchers to Campaign + result = api_instance.add_vouchers_to_campaign(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->add_vouchers_to_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the campaign to which voucher(s) will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. | | +| **vouchers_count** | **Integer** | Number of vouchers that should be added. | [optional] | +| **campaigns_vouchers_create_in_bulk_request_body** | [**CampaignsVouchersCreateInBulkRequestBody**](CampaignsVouchersCreateInBulkRequestBody.md) | Specify the voucher parameters that you would like to overwrite. | [optional] | + +### Return type + +[**CampaignsVouchersCreateResponseBody**](CampaignsVouchersCreateResponseBody.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_campaign + +> create_campaign(opts) + +Create Campaign + +Method to create a batch of vouchers aggregated in one campaign. You can choose a variety of voucher types and define a unique pattern for generating codes. 📘 Global uniqueness All campaign codes are unique across the whole project. Voucherify will not allow you to generate 2 campaigns with the same coupon code. 🚧 Code generation status This is an asynchronous action; you cant read or modify a newly created campaign until the code generation is completed. See the creation_status field in the campaign object description. + +### 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::CampaignsApi.new +opts = { + campaigns_create_request_body: VoucherifySdk::CampaignsCreateDiscountCouponsCampaign.new # CampaignsCreateRequestBody | Specify the details of the campaign that you would like to create. +} + +begin + # Create Campaign + result = api_instance.create_campaign(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->create_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaigns_create_request_body** | [**CampaignsCreateRequestBody**](CampaignsCreateRequestBody.md) | Specify the details of the campaign that you would like to create. | [optional] | + +### Return type + +[**CampaignsCreateResponseBody**](CampaignsCreateResponseBody.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 + + +## delete_campaign + +> delete_campaign(campaign_id, opts) + +Delete Campaign + +Permanently deletes a campaign and all related vouchers. This action cannot be undone. Also, this method immediately removes any redemptions on the voucher. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. +opts = { + force: true # Boolean | If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with exactly the same name. +} + +begin + # Delete Campaign + result = api_instance.delete_campaign(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->delete_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. | | +| **force** | **Boolean** | If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with exactly the same name. | [optional] | + +### Return type + +[**CampaignsDeleteResponseBody**](CampaignsDeleteResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## disable_campaign + +> disable_campaign(campaign_id) + +Disable Campaign + +There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - *enable* and *disable*. Sets campaign state to **inactive**. The vouchers in this campaign can no longer be redeemed. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the campaign being disabled. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + +begin + # Disable Campaign + result = api_instance.disable_campaign(campaign_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->disable_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the campaign being disabled. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. | | + +### Return type + +[**CampaignsDisableResponseBody**](CampaignsDisableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## enable_campaign + +> enable_campaign(campaign_id) + +Enable Campaign + +There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - *enable* and *disable*. Sets campaign state to **active**. The vouchers in this campaign can be redeemed - only if the redemption occurs after the start date of the campaign and voucher and the voucher and campaign are not expired. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. + +begin + # Enable Campaign + result = api_instance.enable_campaign(campaign_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->enable_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. | | + +### Return type + +[**CampaignsEnableResponseBody**](CampaignsEnableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_campaign + +> get_campaign(campaign_id) + +Get Campaign + +Retrieves the campaign with the given campaign ID or campaign name. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + +begin + # Get Campaign + result = api_instance.get_campaign(campaign_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->get_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. | | + +### Return type + +[**CampaignsGetResponseBody**](CampaignsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## import_vouchers_to_campaign + +> import_vouchers_to_campaign(campaign_id, opts) + +Import Vouchers to Campaign + +Imports vouchers to an **existing** campaign. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | The ID of an existing campaign to which youre importing the codes. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. +opts = { + campaigns_import_voucher_item: [VoucherifySdk::CampaignsImportVoucherItem.new({code: 'code_example'})] # Array | Discount type, expiration date and the remaining attributes will be taken from the Campaign settings. +} + +begin + # Import Vouchers to Campaign + result = api_instance.import_vouchers_to_campaign(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->import_vouchers_to_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The ID of an existing campaign to which youre importing the codes. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. | | +| **campaigns_import_voucher_item** | [**Array<CampaignsImportVoucherItem>**](CampaignsImportVoucherItem.md) | Discount type, expiration date and the remaining attributes will be taken from the Campaign settings. | [optional] | + +### Return type + +[**CampaignsImportCreateResponseBody**](CampaignsImportCreateResponseBody.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 + + +## import_vouchers_to_campaign_using_csv + +> import_vouchers_to_campaign_using_csv(campaign_id, file) + +Import Vouchers to Campaign by CSV + +Imports vouchers to an **existing** campaign. The CSV file has to include headers in the first line. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. +file = File.new('/path/to/some/file') # File | File path. + +begin + # Import Vouchers to Campaign by CSV + result = api_instance.import_vouchers_to_campaign_using_csv(campaign_id, file) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->import_vouchers_to_campaign_using_csv: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. | | +| **file** | **File** | File path. | | + +### Return type + +[**CampaignsImportCsvCreateResponseBody**](CampaignsImportCsvCreateResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + + +## list_campaigns + +> list_campaigns(opts) + +List Campaigns + +Retrieve a list of campaigns in a project. The campaigns are returned sorted by creation date, with the most recent campaigns appearing first. When you get a list of campaigns, you can optionally specify query parameters to customize the amount of campaigns returned per call using limit, which page of campaigns to return using page, sort the campaigns using the order query parameter and filter the results by the campaign_type. This method will return an error when trying to return a limit of more than 100 campaigns. + +### 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::CampaignsApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + campaign_type: VoucherifySdk::ParameterCampaignType::PROMOTION, # ParameterCampaignType | This attribute allows filtering by campaign type. + expand: VoucherifySdk::ParameterExpandListCampaigns::CATEGORY, # ParameterExpandListCampaigns | Include an expanded categories object in the response. + order: VoucherifySdk::ParameterOrderListCampaigns::CREATED_AT # ParameterOrderListCampaigns | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. +} + +begin + # List Campaigns + result = api_instance.list_campaigns(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->list_campaigns: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **campaign_type** | [**ParameterCampaignType**](.md) | This attribute allows filtering by campaign type. | [optional] | +| **expand** | [**ParameterExpandListCampaigns**](.md) | Include an expanded categories object in the response. | [optional][default to 'category'] | +| **order** | [**ParameterOrderListCampaigns**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | + +### Return type + +[**CampaignsListResponseBody**](CampaignsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_campaign + +> update_campaign(campaign_id, opts) + +Update Campaign + +Updates the specified campaign by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. Fields other than the ones listed in the request body wont be modified. Even if provided, they will be silently skipped. ## Vouchers will be affected This method will update vouchers aggregated in the campaign. It will affect all vouchers that are not published or redeemed yet. + +### 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::CampaignsApi.new +campaign_id = 'campaign_id_example' # String | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. +opts = { + campaigns_update_request_body: VoucherifySdk::CampaignsUpdateDiscountCouponsCampaign.new # CampaignsUpdateRequestBody | Specify the campaign parameters to be updated. +} + +begin + # Update Campaign + result = api_instance.update_campaign(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CampaignsApi->update_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. | | +| **campaigns_update_request_body** | [**CampaignsUpdateRequestBody**](CampaignsUpdateRequestBody.md) | Specify the campaign parameters to be updated. | [optional] | + +### Return type + +[**CampaignsUpdateResponseBody**](CampaignsUpdateResponseBody.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 + diff --git a/docs/CampaignsCreateBase.md b/docs/CampaignsCreateBase.md new file mode 100644 index 00000000..2283022f --- /dev/null +++ b/docs/CampaignsCreateBase.md @@ -0,0 +1,23 @@ +# VoucherifySdk::CampaignsCreateBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Campaign name. | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign (size of campaign). | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | + diff --git a/docs/CampaignsCreateDiscountCouponsCampaign.md b/docs/CampaignsCreateDiscountCouponsCampaign.md new file mode 100644 index 00000000..29793d2a --- /dev/null +++ b/docs/CampaignsCreateDiscountCouponsCampaign.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CampaignsCreateDiscountCouponsCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Campaign name. | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign (size of campaign). | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **campaign_type** | **String** | Type of campaign. | [optional][default to 'DISCOUNT_COUPONS'] | +| **voucher** | [**DiscountCouponsCampaignVoucher**](DiscountCouponsCampaignVoucher.md) | | [optional] | + diff --git a/docs/CampaignsCreateGiftCampaign.md b/docs/CampaignsCreateGiftCampaign.md new file mode 100644 index 00000000..4a42fdbf --- /dev/null +++ b/docs/CampaignsCreateGiftCampaign.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CampaignsCreateGiftCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Campaign name. | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign (size of campaign). | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **campaign_type** | **String** | Type of campaign. | [optional][default to 'GIFT_VOUCHERS'] | +| **voucher** | [**GiftCampaignVoucher**](GiftCampaignVoucher.md) | | [optional] | + diff --git a/docs/CampaignsCreateGiveawayCampaign.md b/docs/CampaignsCreateGiveawayCampaign.md new file mode 100644 index 00000000..dcf1044b --- /dev/null +++ b/docs/CampaignsCreateGiveawayCampaign.md @@ -0,0 +1,26 @@ +# VoucherifySdk::CampaignsCreateGiveawayCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Campaign name. | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign (size of campaign). | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **campaign_type** | **String** | Type of campaign. | [optional][default to 'LUCKY_DRAW'] | +| **voucher** | [**GiveawayCampaignVoucher**](GiveawayCampaignVoucher.md) | | [optional] | +| **lucky_draw** | [**LuckyDraw**](LuckyDraw.md) | | [optional] | + diff --git a/docs/CampaignsCreateLoyaltyCampaign.md b/docs/CampaignsCreateLoyaltyCampaign.md new file mode 100644 index 00000000..6dc58817 --- /dev/null +++ b/docs/CampaignsCreateLoyaltyCampaign.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CampaignsCreateLoyaltyCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Campaign name. | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign (size of campaign). | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **campaign_type** | **String** | Type of campaign. | [optional][default to 'LOYALTY_PROGRAM'] | +| **voucher** | [**CampaignLoyaltyVoucher**](CampaignLoyaltyVoucher.md) | | [optional] | + diff --git a/docs/CampaignsCreatePromotionCampaign.md b/docs/CampaignsCreatePromotionCampaign.md new file mode 100644 index 00000000..8ecd83e2 --- /dev/null +++ b/docs/CampaignsCreatePromotionCampaign.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CampaignsCreatePromotionCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Campaign name. | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign (size of campaign). | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **campaign_type** | **String** | Type of campaign. | [optional][default to 'PROMOTION'] | +| **promotion** | [**SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion**](SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion.md) | | [optional] | + diff --git a/docs/CampaignsCreateReferralCampaign.md b/docs/CampaignsCreateReferralCampaign.md new file mode 100644 index 00000000..edfafc48 --- /dev/null +++ b/docs/CampaignsCreateReferralCampaign.md @@ -0,0 +1,26 @@ +# VoucherifySdk::CampaignsCreateReferralCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Campaign name. | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign (size of campaign). | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **campaign_type** | **String** | Type of campaign. | [optional][default to 'REFERRAL_PROGRAM'] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | +| **voucher** | [**ReferralCampaignVoucher**](ReferralCampaignVoucher.md) | | [optional] | + diff --git a/docs/CampaignsCreateRequestBody.md b/docs/CampaignsCreateRequestBody.md new file mode 100644 index 00000000..cde29c35 --- /dev/null +++ b/docs/CampaignsCreateRequestBody.md @@ -0,0 +1,57 @@ +# VoucherifySdk::CampaignsCreateRequestBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::CampaignsCreateRequestBody.openapi_one_of +# => +# [ +# :'CampaignsCreateDiscountCouponsCampaign', +# :'CampaignsCreateGiftCampaign', +# :'CampaignsCreateGiveawayCampaign', +# :'CampaignsCreateLoyaltyCampaign', +# :'CampaignsCreatePromotionCampaign', +# :'CampaignsCreateReferralCampaign' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::CampaignsCreateRequestBody.build(data) +# => # + +VoucherifySdk::CampaignsCreateRequestBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `CampaignsCreateDiscountCouponsCampaign` +- `CampaignsCreateGiftCampaign` +- `CampaignsCreateGiveawayCampaign` +- `CampaignsCreateLoyaltyCampaign` +- `CampaignsCreatePromotionCampaign` +- `CampaignsCreateReferralCampaign` +- `nil` (if no type matches) + diff --git a/docs/CampaignsCreateResponseBody.md b/docs/CampaignsCreateResponseBody.md new file mode 100644 index 00000000..63a39cf6 --- /dev/null +++ b/docs/CampaignsCreateResponseBody.md @@ -0,0 +1,37 @@ +# VoucherifySdk::CampaignsCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **name** | **String** | Campaign name. | | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **campaign_type** | **String** | Type of campaign. | | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published | | +| **voucher** | [**CampaignVoucher**](CampaignVoucher.md) | | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **active** | **Boolean** | A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the campaign was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was updated in ISO 8601 format. | [optional] | +| **category** | **String** | Unique category name. | [optional] | +| **creation_status** | **String** | Indicates the status of the campaign creation. | | +| **vouchers_generation_status** | **String** | Indicates the status of the campaign's vouchers. | | +| **protected** | **Boolean** | Indicates whether the resource can be deleted. | | +| **category_id** | **String** | Unique category ID that this campaign belongs to. | | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the campaign. | [default to 'campaign'] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | +| **loyalty_tiers_expiration** | [**LoyaltyTiersExpirationAll**](LoyaltyTiersExpirationAll.md) | | [optional] | +| **promotion** | [**PromotionTiersList**](PromotionTiersList.md) | | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | + diff --git a/docs/CampaignsDeleteResponseBody.md b/docs/CampaignsDeleteResponseBody.md new file mode 100644 index 00000000..8b0226f1 --- /dev/null +++ b/docs/CampaignsDeleteResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignsDeleteResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | [optional] | + diff --git a/docs/CampaignsDisableResponseBody.md b/docs/CampaignsDisableResponseBody.md new file mode 100644 index 00000000..838e4d01 --- /dev/null +++ b/docs/CampaignsDisableResponseBody.md @@ -0,0 +1,7 @@ +# VoucherifySdk::CampaignsDisableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/CampaignsEnableResponseBody.md b/docs/CampaignsEnableResponseBody.md new file mode 100644 index 00000000..fad4cc3d --- /dev/null +++ b/docs/CampaignsEnableResponseBody.md @@ -0,0 +1,7 @@ +# VoucherifySdk::CampaignsEnableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/CampaignsGetResponseBody.md b/docs/CampaignsGetResponseBody.md new file mode 100644 index 00000000..c47fa852 --- /dev/null +++ b/docs/CampaignsGetResponseBody.md @@ -0,0 +1,37 @@ +# VoucherifySdk::CampaignsGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **name** | **String** | Campaign name. | | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **campaign_type** | **String** | Type of campaign. | | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published | | +| **voucher** | [**CampaignVoucher**](CampaignVoucher.md) | | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **active** | **Boolean** | A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the campaign was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was updated in ISO 8601 format. | [optional] | +| **category** | **String** | Unique category name. | [optional] | +| **creation_status** | **String** | Indicates the status of the campaign creation. | | +| **vouchers_generation_status** | **String** | Indicates the status of the campaign's vouchers. | | +| **protected** | **Boolean** | Indicates whether the resource can be deleted. | | +| **category_id** | **String** | Unique category ID that this campaign belongs to. | | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the campaign. | [default to 'campaign'] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | +| **loyalty_tiers_expiration** | [**LoyaltyTiersExpirationAll**](LoyaltyTiersExpirationAll.md) | | [optional] | +| **promotion** | [**PromotionTiersList**](PromotionTiersList.md) | | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | + diff --git a/docs/CampaignsImportCreateResponseBody.md b/docs/CampaignsImportCreateResponseBody.md new file mode 100644 index 00000000..ee03dad6 --- /dev/null +++ b/docs/CampaignsImportCreateResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignsImportCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/CampaignsImportCsvCreateResponseBody.md b/docs/CampaignsImportCsvCreateResponseBody.md new file mode 100644 index 00000000..0e56a97b --- /dev/null +++ b/docs/CampaignsImportCsvCreateResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignsImportCsvCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/CampaignsImportVoucherItem.md b/docs/CampaignsImportVoucherItem.md new file mode 100644 index 00000000..fcc467d0 --- /dev/null +++ b/docs/CampaignsImportVoucherItem.md @@ -0,0 +1,20 @@ +# VoucherifySdk::CampaignsImportVoucherItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | Unique custom voucher code. | | +| **type** | **String** | Type of voucher. | [optional] | +| **redemption** | [**CampaignsImportVoucherItemRedemption**](CampaignsImportVoucherItemRedemption.md) | | [optional] | +| **active** | **Boolean** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**Gift**](Gift.md) | | [optional] | +| **loyalty_card** | [**CampaignsImportVoucherLoyaltyCard**](CampaignsImportVoucherLoyaltyCard.md) | | [optional] | + diff --git a/docs/CampaignsImportVoucherItemRedemption.md b/docs/CampaignsImportVoucherItemRedemption.md new file mode 100644 index 00000000..dc62cee7 --- /dev/null +++ b/docs/CampaignsImportVoucherItemRedemption.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignsImportVoucherItemRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **quantity** | **Integer** | How many times a voucher can be redeemed. A `null` value means unlimited. | [optional] | + diff --git a/docs/CampaignsImportVoucherLoyaltyCard.md b/docs/CampaignsImportVoucherLoyaltyCard.md new file mode 100644 index 00000000..0da00fcb --- /dev/null +++ b/docs/CampaignsImportVoucherLoyaltyCard.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignsImportVoucherLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | The initial number of points to assign to the loyalty card. This is the current loyalty card score i.e. the number of loyalty points on the card. | | + diff --git a/docs/CampaignsListResponseBody.md b/docs/CampaignsListResponseBody.md new file mode 100644 index 00000000..bfd0d12c --- /dev/null +++ b/docs/CampaignsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CampaignsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about campaigns in a dictionary. | [optional][default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of campaign objects. | [optional][default to 'campaigns'] | +| **campaigns** | [**Array<CampaignBase>**](CampaignBase.md) | Contains array of campaign objects. | [optional] | +| **total** | **Integer** | Total number of campaigns. | [optional] | + diff --git a/docs/CampaignsUpdateBase.md b/docs/CampaignsUpdateBase.md new file mode 100644 index 00000000..d976fec0 --- /dev/null +++ b/docs/CampaignsUpdateBase.md @@ -0,0 +1,16 @@ +# VoucherifySdk::CampaignsUpdateBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | + diff --git a/docs/CampaignsUpdateCouponCampaignBase.md b/docs/CampaignsUpdateCouponCampaignBase.md new file mode 100644 index 00000000..74b31cc6 --- /dev/null +++ b/docs/CampaignsUpdateCouponCampaignBase.md @@ -0,0 +1,20 @@ +# VoucherifySdk::CampaignsUpdateCouponCampaignBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | + diff --git a/docs/CampaignsUpdateDiscountCouponsCampaign.md b/docs/CampaignsUpdateDiscountCouponsCampaign.md new file mode 100644 index 00000000..a0ebf728 --- /dev/null +++ b/docs/CampaignsUpdateDiscountCouponsCampaign.md @@ -0,0 +1,21 @@ +# VoucherifySdk::CampaignsUpdateDiscountCouponsCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | + diff --git a/docs/CampaignsUpdateGiftCampaign.md b/docs/CampaignsUpdateGiftCampaign.md new file mode 100644 index 00000000..4f246621 --- /dev/null +++ b/docs/CampaignsUpdateGiftCampaign.md @@ -0,0 +1,21 @@ +# VoucherifySdk::CampaignsUpdateGiftCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **gift** | [**Gift**](Gift.md) | | [optional] | + diff --git a/docs/CampaignsUpdateGiveawayCampaign.md b/docs/CampaignsUpdateGiveawayCampaign.md new file mode 100644 index 00000000..eed0c26d --- /dev/null +++ b/docs/CampaignsUpdateGiveawayCampaign.md @@ -0,0 +1,23 @@ +# VoucherifySdk::CampaignsUpdateGiveawayCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **winners_count** | **String** | It represents the total number of winners in a lucky draw. | [optional] | +| **unique_winners_per_draw** | **String** | It indicates whether each winner in a draw is unique or not. | [optional] | +| **unique_winners** | **String** | Specifies whether each participant can win only once across multiple draws. | [optional] | + diff --git a/docs/CampaignsUpdateLoyaltyCampaign.md b/docs/CampaignsUpdateLoyaltyCampaign.md new file mode 100644 index 00000000..d007340c --- /dev/null +++ b/docs/CampaignsUpdateLoyaltyCampaign.md @@ -0,0 +1,22 @@ +# VoucherifySdk::CampaignsUpdateLoyaltyCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **loyalty_tiers_expiration** | [**LoyaltyTiersExpirationAll**](LoyaltyTiersExpirationAll.md) | | [optional] | +| **options** | [**PropertiesForLoyaltyCampaignOptions**](PropertiesForLoyaltyCampaignOptions.md) | | [optional] | + diff --git a/docs/CampaignsUpdatePromotionCampaign.md b/docs/CampaignsUpdatePromotionCampaign.md new file mode 100644 index 00000000..7b44ad33 --- /dev/null +++ b/docs/CampaignsUpdatePromotionCampaign.md @@ -0,0 +1,16 @@ +# VoucherifySdk::CampaignsUpdatePromotionCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | + diff --git a/docs/CampaignsUpdateReferralCampaign.md b/docs/CampaignsUpdateReferralCampaign.md new file mode 100644 index 00000000..ee359069 --- /dev/null +++ b/docs/CampaignsUpdateReferralCampaign.md @@ -0,0 +1,22 @@ +# VoucherifySdk::CampaignsUpdateReferralCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **unset_metadata_fields** | **Array<String>** | Determine which metadata should be removed from campaign. | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | + diff --git a/docs/CampaignsUpdateRequestBody.md b/docs/CampaignsUpdateRequestBody.md new file mode 100644 index 00000000..c0b4dd33 --- /dev/null +++ b/docs/CampaignsUpdateRequestBody.md @@ -0,0 +1,57 @@ +# VoucherifySdk::CampaignsUpdateRequestBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::CampaignsUpdateRequestBody.openapi_one_of +# => +# [ +# :'CampaignsUpdateDiscountCouponsCampaign', +# :'CampaignsUpdateGiftCampaign', +# :'CampaignsUpdateGiveawayCampaign', +# :'CampaignsUpdateLoyaltyCampaign', +# :'CampaignsUpdatePromotionCampaign', +# :'CampaignsUpdateReferralCampaign' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::CampaignsUpdateRequestBody.build(data) +# => # + +VoucherifySdk::CampaignsUpdateRequestBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `CampaignsUpdateDiscountCouponsCampaign` +- `CampaignsUpdateGiftCampaign` +- `CampaignsUpdateGiveawayCampaign` +- `CampaignsUpdateLoyaltyCampaign` +- `CampaignsUpdatePromotionCampaign` +- `CampaignsUpdateReferralCampaign` +- `nil` (if no type matches) + diff --git a/docs/CampaignsUpdateResponseBody.md b/docs/CampaignsUpdateResponseBody.md new file mode 100644 index 00000000..ec7b10a8 --- /dev/null +++ b/docs/CampaignsUpdateResponseBody.md @@ -0,0 +1,37 @@ +# VoucherifySdk::CampaignsUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **name** | **String** | Campaign name. | | +| **description** | **String** | An optional field to keep any extra textual information about the campaign such as a campaign description and details. | [optional] | +| **campaign_type** | **String** | Type of campaign. | | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published | | +| **voucher** | [**CampaignVoucher**](CampaignVoucher.md) | | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | | +| **use_voucher_metadata_schema** | **Boolean** | Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. | | +| **validity_timeframe** | [**CampaignBaseValidityTimeframe**](CampaignBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **activity_duration_after_publishing** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. | [optional] | +| **vouchers_count** | **Integer** | Total number of unique vouchers in campaign. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **active** | **Boolean** | A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the campaign was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was updated in ISO 8601 format. | [optional] | +| **category** | **String** | Unique category name. | [optional] | +| **creation_status** | **String** | Indicates the status of the campaign creation. | | +| **vouchers_generation_status** | **String** | Indicates the status of the campaign's vouchers. | | +| **protected** | **Boolean** | Indicates whether the resource can be deleted. | | +| **category_id** | **String** | Unique category ID that this campaign belongs to. | | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the campaign. | [default to 'campaign'] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | +| **loyalty_tiers_expiration** | [**LoyaltyTiersExpirationAll**](LoyaltyTiersExpirationAll.md) | | [optional] | +| **promotion** | [**PromotionTiersList**](PromotionTiersList.md) | | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | + diff --git a/docs/CampaignsVouchersCreateBaseRequestBody.md b/docs/CampaignsVouchersCreateBaseRequestBody.md new file mode 100644 index 00000000..7b1a17dd --- /dev/null +++ b/docs/CampaignsVouchersCreateBaseRequestBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::CampaignsVouchersCreateBaseRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **redemption** | [**CampaignsImportVoucherItemRedemption**](CampaignsImportVoucherItemRedemption.md) | | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the voucher starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the voucher expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | + diff --git a/docs/CampaignsVouchersCreateInBulkRequestBody.md b/docs/CampaignsVouchersCreateInBulkRequestBody.md new file mode 100644 index 00000000..30004237 --- /dev/null +++ b/docs/CampaignsVouchersCreateInBulkRequestBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::CampaignsVouchersCreateInBulkRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **redemption** | [**CampaignsImportVoucherItemRedemption**](CampaignsImportVoucherItemRedemption.md) | | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the voucher starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the voucher expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | +| **code** | **String** | Unique voucher code. | [optional] | +| **code_config** | [**CodeConfig**](CodeConfig.md) | | [optional] | + diff --git a/docs/CampaignsVouchersCreateInBulkResponseBody.md b/docs/CampaignsVouchersCreateInBulkResponseBody.md new file mode 100644 index 00000000..9a3edac1 --- /dev/null +++ b/docs/CampaignsVouchersCreateInBulkResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CampaignsVouchersCreateInBulkResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/CampaignsVouchersCreateRequestBody.md b/docs/CampaignsVouchersCreateRequestBody.md new file mode 100644 index 00000000..7bcbf42b --- /dev/null +++ b/docs/CampaignsVouchersCreateRequestBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::CampaignsVouchersCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **category** | **String** | The category assigned to the campaign. Either pass this parameter OR the `category_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **redemption** | [**CampaignsImportVoucherItemRedemption**](CampaignsImportVoucherItemRedemption.md) | | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the voucher starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the voucher expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | + diff --git a/docs/CampaignsVouchersCreateResponseBody.md b/docs/CampaignsVouchersCreateResponseBody.md new file mode 100644 index 00000000..65675733 --- /dev/null +++ b/docs/CampaignsVouchersCreateResponseBody.md @@ -0,0 +1,37 @@ +# VoucherifySdk::CampaignsVouchersCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the voucher. | [optional] | +| **code** | **String** | A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. | [optional] | +| **campaign** | **String** | A unique campaign name, identifies the voucher's parent campaign. | [optional] | +| **campaign_id** | **String** | Assigned by the Voucherify API, identifies the voucher's parent campaign. | [optional] | +| **category** | **String** | Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. | [optional] | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | [optional] | +| **type** | **String** | Defines the type of the voucher. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**VoucherGift**](VoucherGift.md) | | [optional] | +| **loyalty_card** | [**VoucherLoyaltyCard**](VoucherLoyaltyCard.md) | | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**VoucherValidityTimeframe**](VoucherValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **active** | **Boolean** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **assets** | [**VoucherAssets**](VoucherAssets.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the voucher was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. | [optional] | +| **holder_id** | **String** | Unique customer ID of voucher owner. | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. Default is `voucher`. | [optional][default to 'voucher'] | +| **distributions** | **Array<Object>** | | [optional] | +| **deleted** | **Boolean** | Flag indicating whether this voucher is deleted. | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | +| **publish** | [**VoucherPublish**](VoucherPublish.md) | | [optional] | +| **redemption** | [**VoucherRedemption**](VoucherRedemption.md) | | [optional] | + diff --git a/docs/CategoriesApi.md b/docs/CategoriesApi.md new file mode 100644 index 00000000..84bf5153 --- /dev/null +++ b/docs/CategoriesApi.md @@ -0,0 +1,304 @@ +# VoucherifySdk::CategoriesApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_category**](CategoriesApi.md#create_category) | **POST** /v1/categories | Create Category | +| [**delete_category**](CategoriesApi.md#delete_category) | **DELETE** /v1/categories/{categoryId} | Delete Category | +| [**get_category**](CategoriesApi.md#get_category) | **GET** /v1/categories/{categoryId} | Get Category | +| [**list_categories**](CategoriesApi.md#list_categories) | **GET** /v1/categories | List Categories | +| [**update_category**](CategoriesApi.md#update_category) | **PUT** /v1/categories/{categoryId} | Update Category | + + +## create_category + +> create_category(opts) + +Create Category + +Create category with a specific name and hierarchy. + +### 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::CategoriesApi.new +opts = { + categories_create_request_body: VoucherifySdk::CategoriesCreateRequestBody.new({name: 'name_example', hierarchy: 37}) # CategoriesCreateRequestBody | Specify the details of the category that you would like to create. +} + +begin + # Create Category + result = api_instance.create_category(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CategoriesApi->create_category: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **categories_create_request_body** | [**CategoriesCreateRequestBody**](CategoriesCreateRequestBody.md) | Specify the details of the category that you would like to create. | [optional] | + +### Return type + +[**CategoriesCreateResponseBody**](CategoriesCreateResponseBody.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 + + +## delete_category + +> delete_category(category_id) + +Delete Category + +Delete a category by the category ID. + +### 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::CategoriesApi.new +category_id = 'category_id_example' # String | Unique category ID assigned by Voucherify. + +begin + # Delete Category + api_instance.delete_category(category_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling CategoriesApi->delete_category: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## get_category + +> get_category(category_id) + +Get Category + +Retrieve a category by the category ID. + +### 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::CategoriesApi.new +category_id = 'category_id_example' # String | Unique category ID assigned by Voucherify. + +begin + # Get Category + result = api_instance.get_category(category_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CategoriesApi->get_category: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | | + +### Return type + +[**CategoriesGetResponseBody**](CategoriesGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_categories + +> list_categories + +List Categories + +List all categories. + +### 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::CategoriesApi.new + +begin + # List Categories + result = api_instance.list_categories + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CategoriesApi->list_categories: #{e}" +end +``` + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**CategoriesListResponseBody**](CategoriesListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_category + +> update_category(category_id, opts) + +Update Category + +Update category using the category ID. + +### 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::CategoriesApi.new +category_id = 'category_id_example' # String | Unique category ID assigned by Voucherify. +opts = { + categories_update_request_body: VoucherifySdk::CategoriesUpdateRequestBody.new({name: 'name_example', hierarchy: 37}) # CategoriesUpdateRequestBody | Specify the details of the category that you would like to update. +} + +begin + # Update Category + result = api_instance.update_category(category_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CategoriesApi->update_category: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | | +| **categories_update_request_body** | [**CategoriesUpdateRequestBody**](CategoriesUpdateRequestBody.md) | Specify the details of the category that you would like to update. | [optional] | + +### Return type + +[**CategoriesUpdateResponseBody**](CategoriesUpdateResponseBody.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 + diff --git a/docs/CategoriesCreateRequestBody.md b/docs/CategoriesCreateRequestBody.md new file mode 100644 index 00000000..319f0f99 --- /dev/null +++ b/docs/CategoriesCreateRequestBody.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CategoriesCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Category name. | | +| **hierarchy** | **Integer** | Category hierarchy. | | + diff --git a/docs/CategoriesCreateResponseBody.md b/docs/CategoriesCreateResponseBody.md new file mode 100644 index 00000000..31fedbac --- /dev/null +++ b/docs/CategoriesCreateResponseBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::CategoriesCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique category ID assigned by Voucherify. | | +| **name** | **String** | Category name. | | +| **hierarchy** | **Integer** | Category hierarchy. | | +| **object** | **String** | | [default to 'category'] | +| **created_at** | **Time** | Timestamp representing the date and time when the category was created in ISO 8601 format. | | + diff --git a/docs/CategoriesGetResponseBody.md b/docs/CategoriesGetResponseBody.md new file mode 100644 index 00000000..ce0f7bd0 --- /dev/null +++ b/docs/CategoriesGetResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::CategoriesGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique category ID assigned by Voucherify. | | +| **name** | **String** | Category name. | | +| **hierarchy** | **Integer** | Category hierarchy. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the category. | [default to 'category'] | +| **created_at** | **Time** | Timestamp representing the date and time when the category was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the category was updated in ISO 8601 format. | [optional] | +| **stacking_rules_type** | **String** | The type of the stacking rule eligibility. | [optional] | + diff --git a/docs/CategoriesListResponseBody.md b/docs/CategoriesListResponseBody.md new file mode 100644 index 00000000..6d67155c --- /dev/null +++ b/docs/CategoriesListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CategoriesListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about categories in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of category objects. | [default to 'data'] | +| **data** | [**Array<Category>**](Category.md) | | | +| **total** | **Integer** | Total number of categories. | | + diff --git a/docs/CategoriesUpdateRequestBody.md b/docs/CategoriesUpdateRequestBody.md new file mode 100644 index 00000000..efa3979a --- /dev/null +++ b/docs/CategoriesUpdateRequestBody.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CategoriesUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Category name. | | +| **hierarchy** | **Integer** | Category hierarchy. | | + diff --git a/docs/CategoriesUpdateResponseBody.md b/docs/CategoriesUpdateResponseBody.md new file mode 100644 index 00000000..584c84e9 --- /dev/null +++ b/docs/CategoriesUpdateResponseBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::CategoriesUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique category ID assigned by Voucherify. | | +| **name** | **String** | Category name. | | +| **hierarchy** | **Integer** | Category hierarchy. | | +| **object** | **String** | | [default to 'category'] | +| **created_at** | **Time** | Timestamp representing the date and time when the category was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the category was updated in ISO 8601 format. | | + diff --git a/docs/Category.md b/docs/Category.md new file mode 100644 index 00000000..2363e4b0 --- /dev/null +++ b/docs/Category.md @@ -0,0 +1,14 @@ +# VoucherifySdk::Category + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique category ID assigned by Voucherify. | | +| **name** | **String** | Category name. | | +| **hierarchy** | **Integer** | Category hierarchy. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the category. | [default to 'category'] | +| **created_at** | **Time** | Timestamp representing the date and time when the category was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the category was updated in ISO 8601 format. | [optional] | +| **stacking_rules_type** | **String** | The type of the stacking rule eligibility. | [optional] | + diff --git a/docs/ClientEventsCreateRequestBody.md b/docs/ClientEventsCreateRequestBody.md new file mode 100644 index 00000000..6ab123e5 --- /dev/null +++ b/docs/ClientEventsCreateRequestBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::ClientEventsCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event** | **String** | Event name. This is the same name that you used to define a custom event in the **Dashboard** > **Project Settings** > **Event Schema**. | | +| **customer** | [**Customer**](Customer.md) | | | +| **referral** | [**ClientEventsCreateRequestBodyReferral**](ClientEventsCreateRequestBodyReferral.md) | | [optional] | +| **loyalty** | [**ClientEventsCreateRequestBodyLoyalty**](ClientEventsCreateRequestBodyLoyalty.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the event. A set of key/value pairs that you can attach to an event object. It can be useful for storing additional information about the event in a structured format. Event metadata schema is defined in the **Dashboard** > **Project Settings** > **Event Schema** > **Edit particular event** > **Metadata property definition**. | [optional] | + diff --git a/docs/ClientEventsCreateRequestBodyLoyalty.md b/docs/ClientEventsCreateRequestBodyLoyalty.md new file mode 100644 index 00000000..02eedd55 --- /dev/null +++ b/docs/ClientEventsCreateRequestBodyLoyalty.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ClientEventsCreateRequestBodyLoyalty + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | Code of the loyalty card to receive points based on the calculation method defined in the related earning rule. An earning rule is triggered for the loyalty card when the event passed in the `event` parameter of the request payload gets sent along with this loyalty card code. | | + diff --git a/docs/ClientEventsCreateRequestBodyReferral.md b/docs/ClientEventsCreateRequestBodyReferral.md new file mode 100644 index 00000000..7ff8ffe6 --- /dev/null +++ b/docs/ClientEventsCreateRequestBodyReferral.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ClientEventsCreateRequestBodyReferral + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A code through which a new visitor has been referred to a service. | | +| **referrer_id** | **String** | Unique ID of the referring person - it is optional and not required if the referral **code** is provided. | [optional] | + diff --git a/docs/ClientEventsCreateResponseBody.md b/docs/ClientEventsCreateResponseBody.md new file mode 100644 index 00000000..3629c2f5 --- /dev/null +++ b/docs/ClientEventsCreateResponseBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::ClientEventsCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The object represented is an `event`. | [default to 'event'] | +| **type** | **String** | The event name. | | +| **customer** | [**SimpleCustomerRequiredObjectType**](SimpleCustomerRequiredObjectType.md) | | | +| **referral** | **Object** | A `null` referral object. | | +| **loyalty** | **Object** | A `null` loyalty object. | | + diff --git a/docs/ClientQualificationsCheckEligibilityRequestBody.md b/docs/ClientQualificationsCheckEligibilityRequestBody.md new file mode 100644 index 00000000..d6e6f1bc --- /dev/null +++ b/docs/ClientQualificationsCheckEligibilityRequestBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ClientQualificationsCheckEligibilityRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **order** | [**Order**](Order.md) | | [optional] | +| **mode** | **String** | Defines which resources Voucherify will use. The `ADVANCED` mode is available after purchase only. | [optional] | +| **tracking_id** | **String** | Is correspondent to Customer's source_id | [optional] | +| **scenario** | **String** | Defines the scenario Voucherify should consider during the qualification process. - `ALL` - Scenario that returns all redeemables available for the customer in one API request. This scenario is used by default when no value is selected. - `CUSTOMER_WALLET` - returns vouchers applicable to the customer’s cart based on the vouchers assigned to the customer’s profile. - `AUDIENCE_ONLY` - returns all vouchers, promotion tiers, and campaigns available to the customer. Voucherify validates the rules based on the customer profile only. - `PRODUCTS` - returns all promotions available for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT` - returns all promotions available for products when a discount is defined as applicable to specific item(s). - `PROMOTION_STACKS` - returns the applicable promotion stacks. - `PRODUCTS_BY_CUSTOMER` - returns all promotions available for a customer for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT_BY_CUSTOMER` - returns all promotions available for a customer for products when a discount is defined as applicable to specific item(s). | [optional] | +| **options** | [**QualificationsOption**](QualificationsOption.md) | | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can send in the request body to check against redeemables requiring **redemption** metadata validation rules to be satisfied. The validation runs against rules that are defined through the <!-- [Create Validation Rules](https://docs.voucherify.io/reference/create-validation-rules) -->[Create Validation Rules](ref:create-validation-rules) endpoint or via the Dashboard; in the _Advanced Rule Builder_ &rarr; _Advanced_ &rarr; _Redemption metadata satisfy_ or _Basic Builder_ &rarr; _Attributes match_ &rarr; _REDEMPTION METADATA_. [Read more](https://support.voucherify.io/article/148-how-to-build-a-rule). | [optional] | + diff --git a/docs/ClientQualificationsCheckEligibilityRequestBodyOptions.md b/docs/ClientQualificationsCheckEligibilityRequestBodyOptions.md new file mode 100644 index 00000000..671a8296 --- /dev/null +++ b/docs/ClientQualificationsCheckEligibilityRequestBodyOptions.md @@ -0,0 +1,12 @@ +# VoucherifySdk::ClientQualificationsCheckEligibilityRequestBodyOptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | The maximum number of redeemables to be returned in the API request. The actual number of returned redeemables will be determined by the API. The default value is set to 5 | [optional] | +| **starting_after** | **Time** | Cursor used for paging. | [optional] | +| **filters** | [**ClientQualificationsCheckEligibilityRequestBodyOptionsFilters**](ClientQualificationsCheckEligibilityRequestBodyOptionsFilters.md) | | [optional] | +| **expand** | **Array<String>** | The expand array lets you configure the parameters included in the response. Depending on the strings included in the array, the response will contain different details. | **Expand Option** | **Response Body** | |:---|:---| | [\"redeemable\"] | - Returns the redeemables' metadata. | | [\"category\"] | - Returns an expanded `categories` object, showing details about the category. | | [\"validation_rules\"] | - Returns an expanded `validation_rules` object, showing details about the validation rules. | | [optional] | +| **sorting_rule** | **String** | Is used to determine the order in which data is displayed in the result array. - `DEFAULT` - Sorting descending by `created_at` - `BEST_DEAL` - Sorting descending by `total_applied_discount_amount` - `LEAST_DEAL` - Sorting ascending by `total_applied_discount_amount` | [optional] | + diff --git a/docs/ClientQualificationsCheckEligibilityRequestBodyOptionsFilters.md b/docs/ClientQualificationsCheckEligibilityRequestBodyOptionsFilters.md new file mode 100644 index 00000000..5e60b5a8 --- /dev/null +++ b/docs/ClientQualificationsCheckEligibilityRequestBodyOptionsFilters.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ClientQualificationsCheckEligibilityRequestBodyOptionsFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **category_id** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **campaign_id** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **resource_id** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **resource_type** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **voucher_type** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **code** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | + diff --git a/docs/ClientQualificationsCheckEligibilityResponseBody.md b/docs/ClientQualificationsCheckEligibilityResponseBody.md new file mode 100644 index 00000000..cc0f797a --- /dev/null +++ b/docs/ClientQualificationsCheckEligibilityResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ClientQualificationsCheckEligibilityResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables** | [**QualificationsRedeemables**](QualificationsRedeemables.md) | | [optional] | +| **tracking_id** | **String** | This identifier is generated during voucher qualification based on your internal id (e.g., email, database ID). This is a hashed customer source ID. | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **stacking_rules** | [**StackingRules**](StackingRules.md) | | [optional] | + diff --git a/docs/ClientRedemptionsRedeemRequestBody.md b/docs/ClientRedemptionsRedeemRequestBody.md new file mode 100644 index 00000000..5cdc25b3 --- /dev/null +++ b/docs/ClientRedemptionsRedeemRequestBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ClientRedemptionsRedeemRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables** | [**Array<StackableValidateRedeemBaseRedeemablesItem>**](StackableValidateRedeemBaseRedeemablesItem.md) | An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. | | +| **order** | [**Order**](Order.md) | | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | +| **tracking_id** | **String** | Is correspondent to Customer's source_id | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. | [optional] | +| **options** | [**ClientRedemptionsRedeemRequestBodyAllOfOptions**](ClientRedemptionsRedeemRequestBodyAllOfOptions.md) | | [optional] | + diff --git a/docs/ClientRedemptionsRedeemRequestBodyAllOfOptions.md b/docs/ClientRedemptionsRedeemRequestBodyAllOfOptions.md new file mode 100644 index 00000000..980f60d6 --- /dev/null +++ b/docs/ClientRedemptionsRedeemRequestBodyAllOfOptions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ClientRedemptionsRedeemRequestBodyAllOfOptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **expand** | **Array<String>** | Expand array lets you configure params included in the response. Depending on the strings included in the array, the response will contain different details. | **Expand Option** | **Response Body** | |:---|:---| | [\"order\"] | - Same response as fallback response (without an options object).<br>- Order data with calculated discounts are listed in each child redeemable object.<br>- Metadata not included for each discount type. | | [\"redeemable\"] | Expands redeemable objects by including `metadata` for each discount type. | | [\"order\", \"redeemable\"] | - Order data with calculated discounts are listed in each child redeemable object.<br>- Includes `metadata` for each discount type. | | [\"redeemable\", \"redemption\", \"category\"] | - Returns each discount type's `metadata` in each child redemption object.<br>- Returns redemption object `metadata`.<br>- Returns an expanded `categories` object, showing details about the category. | | [optional] | + diff --git a/docs/ClientRedemptionsRedeemResponseBody.md b/docs/ClientRedemptionsRedeemResponseBody.md new file mode 100644 index 00000000..f0f0db34 --- /dev/null +++ b/docs/ClientRedemptionsRedeemResponseBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::ClientRedemptionsRedeemResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemptions** | [**Array<Redemption>**](Redemption.md) | | [optional] | +| **parent_redemption** | [**Redemption**](Redemption.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **inapplicable_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each inapplicable redeemable. | [optional] | +| **skipped_redeemables** | [**Array<ValidationsRedeemableSkipped>**](ValidationsRedeemableSkipped.md) | Lists validation results of each redeemable. If a redeemable can be applied, the API returns `\"status\": \"APPLICABLE\"`. | [optional] | + diff --git a/docs/ClientSideApi.md b/docs/ClientSideApi.md new file mode 100644 index 00000000..15820557 --- /dev/null +++ b/docs/ClientSideApi.md @@ -0,0 +1,319 @@ +# VoucherifySdk::ClientSideApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**check_eligibility_client_side**](ClientSideApi.md#check_eligibility_client_side) | **POST** /client/v1/qualifications | Check Eligibility (client-side) | +| [**redeem_stacked_discounts_client_side**](ClientSideApi.md#redeem_stacked_discounts_client_side) | **POST** /client/v1/redemptions | Redeem Stackable Discounts (client-side) | +| [**track_custom_event_client_side**](ClientSideApi.md#track_custom_event_client_side) | **POST** /client/v1/events | Track Custom Event (client-side) | +| [**update_customers_consents_client_side**](ClientSideApi.md#update_customers_consents_client_side) | **PUT** /client/v1/customers/{customerId}/consents | Update Customer's consents (client-side) | +| [**validate_stacked_discounts_client_side**](ClientSideApi.md#validate_stacked_discounts_client_side) | **POST** /client/v1/validations | Validate Stackable Discounts (client-side) | + + +## check_eligibility_client_side + +> check_eligibility_client_side(opts) + +Check Eligibility (client-side) + +Generate a list of redeemables that are applicable in the context of the customer and order. The new qualifications method is an improved version of Campaign Qualifications, Voucher Qualifications, and Promotions Validation API requests. The new qualification method introduces the following improvements: - Qualification results are returned faster - No limit on the number of returned redeemables - Introduces new qualification scenarios, not available in the previous version 👍 Scenario Guide Read our dedicated guide to learn about some use cases this endpoint can cover here. # Paging The Voucherify Qualifications API request will return to you all of the redeemables available for the customer in batches of up to 50 redeemables. To get the next batch of redeemables, you need to use the starting_after cursor. To process of paging the redeemables works in the following manner: - You send the first API request for Qualifications without the starting_after parameter. - The response will contain a parameter named has_more. If the parameters value is set to true, then more redeemables are available. - Get the value of the created_at parameter of the last returned redeemable. The value of this parameter will be used as a cursor to retrieve the next page of redeemables. - Send another API request for Qualification with the starting_after parameter set to the value taken from the created_at parameter from the last returned redeemable. - Voucherify will return the next page of redeemables. - If the has_more parameter is set to true, apply steps 3-5 to get the next page of redeemables. + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' +# setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-Client-Application-Id + config.api_key['X-Client-Application-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-Client-Application-Id'] = 'Bearer' + + # Configure API key authorization: X-Client-Token + config.api_key['X-Client-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-Client-Token'] = 'Bearer' +end + +api_instance = VoucherifySdk::ClientSideApi.new +opts = { + client_qualifications_check_eligibility_request_body: VoucherifySdk::ClientQualificationsCheckEligibilityRequestBody.new # ClientQualificationsCheckEligibilityRequestBody | Define order and customer context. +} + +begin + # Check Eligibility (client-side) + result = api_instance.check_eligibility_client_side(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ClientSideApi->check_eligibility_client_side: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **client_qualifications_check_eligibility_request_body** | [**ClientQualificationsCheckEligibilityRequestBody**](ClientQualificationsCheckEligibilityRequestBody.md) | Define order and customer context. | [optional] | + +### Return type + +[**ClientQualificationsCheckEligibilityResponseBody**](ClientQualificationsCheckEligibilityResponseBody.md) + +### Authorization + +[X-Client-Application-Id](../README.md#X-Client-Application-Id), [X-Client-Token](../README.md#X-Client-Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## redeem_stacked_discounts_client_side + +> redeem_stacked_discounts_client_side(origin, opts) + +Redeem Stackable Discounts (client-side) + +This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. # How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: 📘 Rollbacks You cant roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your rollback request. + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' +# setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-Client-Application-Id + config.api_key['X-Client-Application-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-Client-Application-Id'] = 'Bearer' + + # Configure API key authorization: X-Client-Token + config.api_key['X-Client-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-Client-Token'] = 'Bearer' +end + +api_instance = VoucherifySdk::ClientSideApi.new +origin = 'origin_example' # String | Indicates the origin (scheme, hostname, and port). +opts = { + client_redemptions_redeem_request_body: VoucherifySdk::ClientRedemptionsRedeemRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # ClientRedemptionsRedeemRequestBody | +} + +begin + # Redeem Stackable Discounts (client-side) + result = api_instance.redeem_stacked_discounts_client_side(origin, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ClientSideApi->redeem_stacked_discounts_client_side: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **origin** | **String** | Indicates the origin (scheme, hostname, and port). | | +| **client_redemptions_redeem_request_body** | [**ClientRedemptionsRedeemRequestBody**](ClientRedemptionsRedeemRequestBody.md) | | [optional] | + +### Return type + +[**ClientRedemptionsRedeemResponseBody**](ClientRedemptionsRedeemResponseBody.md) + +### Authorization + +[X-Client-Application-Id](../README.md#X-Client-Application-Id), [X-Client-Token](../README.md#X-Client-Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## track_custom_event_client_side + +> track_custom_event_client_side(origin, opts) + +Track Custom Event (client-side) + +To track a custom event, you create an event object. The event object must be linked to the customer who performs the action. If a customer doesnt exist in Voucherify, the customer will be created. + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' +# setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-Client-Application-Id + config.api_key['X-Client-Application-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-Client-Application-Id'] = 'Bearer' + + # Configure API key authorization: X-Client-Token + config.api_key['X-Client-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-Client-Token'] = 'Bearer' +end + +api_instance = VoucherifySdk::ClientSideApi.new +origin = 'origin_example' # String | Indicates the origin (scheme, hostname, and port). +opts = { + client_events_create_request_body: VoucherifySdk::ClientEventsCreateRequestBody.new({event: 'event_example', customer: VoucherifySdk::Customer.new}) # ClientEventsCreateRequestBody | Specify the details of the custom event. +} + +begin + # Track Custom Event (client-side) + result = api_instance.track_custom_event_client_side(origin, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ClientSideApi->track_custom_event_client_side: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **origin** | **String** | Indicates the origin (scheme, hostname, and port). | | +| **client_events_create_request_body** | [**ClientEventsCreateRequestBody**](ClientEventsCreateRequestBody.md) | Specify the details of the custom event. | [optional] | + +### Return type + +[**ClientEventsCreateResponseBody**](ClientEventsCreateResponseBody.md) + +### Authorization + +[X-Client-Application-Id](../README.md#X-Client-Application-Id), [X-Client-Token](../README.md#X-Client-Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## update_customers_consents_client_side + +> update_customers_consents_client_side(customer_id, opts) + +Update Customer's consents (client-side) + +Update marketing permissions for the specified customer. + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' +# setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-Client-Application-Id + config.api_key['X-Client-Application-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-Client-Application-Id'] = 'Bearer' + + # Configure API key authorization: X-Client-Token + config.api_key['X-Client-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-Client-Token'] = 'Bearer' +end + +api_instance = VoucherifySdk::ClientSideApi.new +customer_id = 'customer_id_example' # String | A Voucherify customer identifier or source_id +opts = { + body: { ... } # Object | Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: +} + +begin + # Update Customer's consents (client-side) + api_instance.update_customers_consents_client_side(customer_id, opts) +rescue VoucherifySdk::ApiError => e + puts "Error when calling ClientSideApi->update_customers_consents_client_side: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | A Voucherify customer identifier or source_id | | +| **body** | **Object** | Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: | [optional] | + +### Return type + +nil (empty response body) + +### Authorization + +[X-Client-Application-Id](../README.md#X-Client-Application-Id), [X-Client-Token](../README.md#X-Client-Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: Not defined + + +## validate_stacked_discounts_client_side + +> validate_stacked_discounts_client_side(origin, opts) + +Validate Stackable Discounts (client-side) + +Verify redeemables provided in the request. This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' +# setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-Client-Application-Id + config.api_key['X-Client-Application-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-Client-Application-Id'] = 'Bearer' + + # Configure API key authorization: X-Client-Token + config.api_key['X-Client-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-Client-Token'] = 'Bearer' +end + +api_instance = VoucherifySdk::ClientSideApi.new +origin = 'origin_example' # String | Indicates the origin (scheme, hostname, and port). +opts = { + client_validations_validate_request_body: VoucherifySdk::ClientValidationsValidateRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # ClientValidationsValidateRequestBody | +} + +begin + # Validate Stackable Discounts (client-side) + result = api_instance.validate_stacked_discounts_client_side(origin, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ClientSideApi->validate_stacked_discounts_client_side: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **origin** | **String** | Indicates the origin (scheme, hostname, and port). | | +| **client_validations_validate_request_body** | [**ClientValidationsValidateRequestBody**](ClientValidationsValidateRequestBody.md) | | [optional] | + +### Return type + +[**ClientValidationsValidateResponseBody**](ClientValidationsValidateResponseBody.md) + +### Authorization + +[X-Client-Application-Id](../README.md#X-Client-Application-Id), [X-Client-Token](../README.md#X-Client-Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + diff --git a/docs/ClientValidationsValidateRequestBody.md b/docs/ClientValidationsValidateRequestBody.md new file mode 100644 index 00000000..c4184377 --- /dev/null +++ b/docs/ClientValidationsValidateRequestBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ClientValidationsValidateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables** | [**Array<StackableValidateRedeemBaseRedeemablesItem>**](StackableValidateRedeemBaseRedeemablesItem.md) | An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. | | +| **order** | [**Order**](Order.md) | | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | +| **tracking_id** | **String** | Is correspondent to Customer's source_id | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. | [optional] | +| **options** | [**ClientValidationsValidateRequestBodyAllOfOptions**](ClientValidationsValidateRequestBodyAllOfOptions.md) | | [optional] | + diff --git a/docs/ClientValidationsValidateRequestBodyAllOfOptions.md b/docs/ClientValidationsValidateRequestBodyAllOfOptions.md new file mode 100644 index 00000000..e681221b --- /dev/null +++ b/docs/ClientValidationsValidateRequestBodyAllOfOptions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ClientValidationsValidateRequestBodyAllOfOptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **expand** | **Array<String>** | The expand array lets you configure the parameters included in the response. Depending on the strings included in the array, the response will contain different details. | **Expand Option** | **Response Body** | |:---|:---| | [\"order\"] | - Same response as fallback response (without an options object).<br>- Order data with calculated discounts are listed in each child redeemable object.<br>- Metadata not included for each discount type. | | [\"redeemable\"] | Expands redeemable objects by including `metadata` for each discount type. | | [\"order\", \"redeemable\"] | - Order data with calculated discounts are listed in each child redeemable object.<br>- Includes `metadata` for each discount type. | | [\"category\"] | - Returns an expanded `categories` object, showing details about the category. | | [optional] | + diff --git a/docs/ClientValidationsValidateResponseBody.md b/docs/ClientValidationsValidateResponseBody.md new file mode 100644 index 00000000..b95477b5 --- /dev/null +++ b/docs/ClientValidationsValidateResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ClientValidationsValidateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **valid** | **Boolean** | The result of the validation. It takes all of the redeemables into account and returns a `false` if at least one redeemable is inapplicable. Returns `true` if all redeemables are applicable. | | +| **redeemables** | [**Array<ValidationsValidateAllResponseBodyRedeemablesItem>**](ValidationsValidateAllResponseBodyRedeemablesItem.md) | Lists validation results of each redeemable. If redeemables_application_mode=\"PARTIAL\" all redeemables here will be \"APPLICABLE\" | | +| **skipped_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each skipped redeemable. | [optional] | +| **inapplicable_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each inapplicable redeemable. | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **tracking_id** | **String** | Hashed customer source ID. | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | + diff --git a/docs/CodeConfig.md b/docs/CodeConfig.md new file mode 100644 index 00000000..7c57bdd3 --- /dev/null +++ b/docs/CodeConfig.md @@ -0,0 +1,13 @@ +# VoucherifySdk::CodeConfig + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **length** | **Float** | Number of characters in a generated code (excluding prefix and postfix). | [optional] | +| **charset** | **String** | Characters that can appear in the code. Examples: - Alphanumeric: `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic: `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic Lowercase: `abcdefghijklmnopqrstuvwxyz` - Alphabetic Uppercase: `ABCDEFGHIJKLMNOPQRSTUVWXYZ` - Numbers: `0123456789` - Custom: a custom character set | [optional] | +| **prefix** | **String** | A text appended before the code. | [optional] | +| **postfix** | **String** | A text appended after the code. | [optional] | +| **pattern** | **String** | A pattern for codes where hashes (#) will be replaced with random characters. Overrides `length`. | [optional] | +| **initial_count** | **Integer** | The initial count | [optional] | + diff --git a/docs/CodeConfigRequiredLengthCharsetPattern.md b/docs/CodeConfigRequiredLengthCharsetPattern.md new file mode 100644 index 00000000..1c5375c6 --- /dev/null +++ b/docs/CodeConfigRequiredLengthCharsetPattern.md @@ -0,0 +1,13 @@ +# VoucherifySdk::CodeConfigRequiredLengthCharsetPattern + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **length** | **Float** | Number of characters in a generated code (excluding prefix and postfix). | | +| **charset** | **String** | Characters that can appear in the code. Examples: - Alphanumeric: `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic: `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic Lowercase: `abcdefghijklmnopqrstuvwxyz` - Alphabetic Uppercase: `ABCDEFGHIJKLMNOPQRSTUVWXYZ` - Numbers: `0123456789` - Custom: a custom character set | | +| **prefix** | **String** | A text appended before the code. | [optional] | +| **postfix** | **String** | A text appended after the code. | [optional] | +| **pattern** | **String** | A pattern for codes where hashes (#) will be replaced with random characters. Overrides `length`. | | +| **initial_count** | **Integer** | The initial count | [optional] | + diff --git a/docs/CreatePublicationBase.md b/docs/CreatePublicationBase.md new file mode 100644 index 00000000..cce1f64d --- /dev/null +++ b/docs/CreatePublicationBase.md @@ -0,0 +1,10 @@ +# VoucherifySdk::CreatePublicationBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If `source_id` is provided only 1 voucher can be published per request. | [optional] | +| **customer** | [**Customer**](Customer.md) | | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | [optional] | + diff --git a/docs/CreatePublicationCampaign.md b/docs/CreatePublicationCampaign.md new file mode 100644 index 00000000..3071e239 --- /dev/null +++ b/docs/CreatePublicationCampaign.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CreatePublicationCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Name of voucher's parent campaign or unique campaign ID that was assigned by Voucherify. | | +| **count** | **Integer** | Number of vouchers to be published to customer. | [optional] | + diff --git a/docs/CreatePublicationWithCampaign.md b/docs/CreatePublicationWithCampaign.md new file mode 100644 index 00000000..61b027bf --- /dev/null +++ b/docs/CreatePublicationWithCampaign.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CreatePublicationWithCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If `source_id` is provided only 1 voucher can be published per request. | [optional] | +| **customer** | [**Customer**](Customer.md) | | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | [optional] | +| **campaign** | [**CreatePublicationCampaign**](CreatePublicationCampaign.md) | | | + diff --git a/docs/CreatePublicationWithSpecificVoucher.md b/docs/CreatePublicationWithSpecificVoucher.md new file mode 100644 index 00000000..5ced831b --- /dev/null +++ b/docs/CreatePublicationWithSpecificVoucher.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CreatePublicationWithSpecificVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If `source_id` is provided only 1 voucher can be published per request. | [optional] | +| **customer** | [**Customer**](Customer.md) | | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | [optional] | +| **voucher** | **String** | Code of voucher being published. | | + diff --git a/docs/CustomEvent.md b/docs/CustomEvent.md new file mode 100644 index 00000000..9cd728d6 --- /dev/null +++ b/docs/CustomEvent.md @@ -0,0 +1,15 @@ +# VoucherifySdk::CustomEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique custom event ID. | [optional] | +| **object** | **String** | The object represented is an `event`. | [default to 'event'] | +| **type** | **String** | The event name. | | +| **customer** | [**SimpleCustomerRequiredObjectType**](SimpleCustomerRequiredObjectType.md) | | | +| **referral** | [**CustomEventReferral**](CustomEventReferral.md) | | | +| **loyalty** | **Object** | | | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the custom event. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the custom event was created in ISO 8601 format. | [optional] | + diff --git a/docs/CustomEventReferral.md b/docs/CustomEventReferral.md new file mode 100644 index 00000000..a8a40f41 --- /dev/null +++ b/docs/CustomEventReferral.md @@ -0,0 +1,10 @@ +# VoucherifySdk::CustomEventReferral + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **code** | **String** | Voucher code. | [optional] | +| **id** | **String** | Unique voucher ID. | [optional] | + diff --git a/docs/Customer.md b/docs/Customer.md new file mode 100644 index 00000000..7d2082c7 --- /dev/null +++ b/docs/Customer.md @@ -0,0 +1,17 @@ +# VoucherifySdk::Customer + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | +| **id** | **String** | The ID of an existing customer. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | + diff --git a/docs/CustomerActivity.md b/docs/CustomerActivity.md new file mode 100644 index 00000000..7812b134 --- /dev/null +++ b/docs/CustomerActivity.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CustomerActivity + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique event ID, assigned by Voucherify. | [optional] | +| **type** | **String** | Event type. | [optional] | +| **data** | [**Array<CustomerActivityData>**](CustomerActivityData.md) | Contains details about the event. The objects that are returned in the data attribute differ based on the context of the event type. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the customer activity occurred in ISO 8601 format. | [optional] | + diff --git a/docs/CustomerActivityData.md b/docs/CustomerActivityData.md new file mode 100644 index 00000000..6cb4c706 --- /dev/null +++ b/docs/CustomerActivityData.md @@ -0,0 +1,183 @@ +# VoucherifySdk::CustomerActivityData + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::CustomerActivityData.openapi_one_of +# => +# [ +# :'EventCustomerActiveCampaignFailed', +# :'EventCustomerActiveCampaignRecovered', +# :'EventCustomerActiveCampaignSent', +# :'EventCustomerBatchFailed', +# :'EventCustomerBatchRecovered', +# :'EventCustomerBatchSent', +# :'EventCustomerBrazeFailed', +# :'EventCustomerBrazeRecovered', +# :'EventCustomerBrazeSent', +# :'EventCustomerConfirmed', +# :'EventCustomerConsentsGiven', +# :'EventCustomerConsentsRevoked', +# :'EventCustomerCreated', +# :'EventCustomerCustomEvent', +# :'EventCustomerDeleted', +# :'EventCustomerEmailFailed', +# :'EventCustomerEmailRecovered', +# :'EventCustomerEmailSent', +# :'EventCustomerGiftVoucherBalanceAdded', +# :'EventCustomerIntercomFailed', +# :'EventCustomerIntercomRecovered', +# :'EventCustomerIntercomSent', +# :'EventCustomerKlaviyoFailed', +# :'EventCustomerKlaviyoRecovered', +# :'EventCustomerKlaviyoSent', +# :'EventCustomerLoyaltyCardPointsAdded', +# :'EventCustomerLoyaltyCardPointsTransferred', +# :'EventCustomerLoyaltyTierDowngraded', +# :'EventCustomerLoyaltyTierExpirationChanged', +# :'EventCustomerLoyaltyTierJoined', +# :'EventCustomerLoyaltyTierLeft', +# :'EventCustomerLoyaltyTierProlonged', +# :'EventCustomerLoyaltyTierUpgraded', +# :'EventCustomerLoyaltyUpdated', +# :'EventCustomerMailchimpFailed', +# :'EventCustomerMailchimpRecovered', +# :'EventCustomerMailchimpSent', +# :'EventCustomerOrderCanceled', +# :'EventCustomerOrderCreated', +# :'EventCustomerOrderFulfilled', +# :'EventCustomerOrderPaid', +# :'EventCustomerOrderProcessing', +# :'EventCustomerOrderUpdated', +# :'EventCustomerPublicationFailed', +# :'EventCustomerPublicationSucceeded', +# :'EventCustomerRedemptionFailed', +# :'EventCustomerRedemptionRollbackFailed', +# :'EventCustomerRedemptionRollbackSucceeded', +# :'EventCustomerRedemptionSucceeded', +# :'EventCustomerReferred', +# :'EventCustomerRewardRedemptionsCompleted', +# :'EventCustomerRewardRedemptionsCreated', +# :'EventCustomerRewardRedemptionsPending', +# :'EventCustomerRewardRedemptionsRolledBack', +# :'EventCustomerRewarded', +# :'EventCustomerRewardedLoyaltyPoints', +# :'EventCustomerSegmentEntered', +# :'EventCustomerSegmentLeft', +# :'EventCustomerShopifyFailed', +# :'EventCustomerShopifyRecovered', +# :'EventCustomerShopifySent', +# :'EventCustomerSmsFailed', +# :'EventCustomerSmsRecovered', +# :'EventCustomerSmsSent', +# :'EventCustomerUpdated', +# :'EventCustomerValidationFailed', +# :'EventCustomerValidationSucceeded', +# :'EventCustomerVoucherDeleted', +# :'EventCustomerVouchersLoyaltyPointsExpired' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::CustomerActivityData.build(data) +# => # + +VoucherifySdk::CustomerActivityData.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `EventCustomerActiveCampaignFailed` +- `EventCustomerActiveCampaignRecovered` +- `EventCustomerActiveCampaignSent` +- `EventCustomerBatchFailed` +- `EventCustomerBatchRecovered` +- `EventCustomerBatchSent` +- `EventCustomerBrazeFailed` +- `EventCustomerBrazeRecovered` +- `EventCustomerBrazeSent` +- `EventCustomerConfirmed` +- `EventCustomerConsentsGiven` +- `EventCustomerConsentsRevoked` +- `EventCustomerCreated` +- `EventCustomerCustomEvent` +- `EventCustomerDeleted` +- `EventCustomerEmailFailed` +- `EventCustomerEmailRecovered` +- `EventCustomerEmailSent` +- `EventCustomerGiftVoucherBalanceAdded` +- `EventCustomerIntercomFailed` +- `EventCustomerIntercomRecovered` +- `EventCustomerIntercomSent` +- `EventCustomerKlaviyoFailed` +- `EventCustomerKlaviyoRecovered` +- `EventCustomerKlaviyoSent` +- `EventCustomerLoyaltyCardPointsAdded` +- `EventCustomerLoyaltyCardPointsTransferred` +- `EventCustomerLoyaltyTierDowngraded` +- `EventCustomerLoyaltyTierExpirationChanged` +- `EventCustomerLoyaltyTierJoined` +- `EventCustomerLoyaltyTierLeft` +- `EventCustomerLoyaltyTierProlonged` +- `EventCustomerLoyaltyTierUpgraded` +- `EventCustomerLoyaltyUpdated` +- `EventCustomerMailchimpFailed` +- `EventCustomerMailchimpRecovered` +- `EventCustomerMailchimpSent` +- `EventCustomerOrderCanceled` +- `EventCustomerOrderCreated` +- `EventCustomerOrderFulfilled` +- `EventCustomerOrderPaid` +- `EventCustomerOrderProcessing` +- `EventCustomerOrderUpdated` +- `EventCustomerPublicationFailed` +- `EventCustomerPublicationSucceeded` +- `EventCustomerRedemptionFailed` +- `EventCustomerRedemptionRollbackFailed` +- `EventCustomerRedemptionRollbackSucceeded` +- `EventCustomerRedemptionSucceeded` +- `EventCustomerReferred` +- `EventCustomerRewardRedemptionsCompleted` +- `EventCustomerRewardRedemptionsCreated` +- `EventCustomerRewardRedemptionsPending` +- `EventCustomerRewardRedemptionsRolledBack` +- `EventCustomerRewarded` +- `EventCustomerRewardedLoyaltyPoints` +- `EventCustomerSegmentEntered` +- `EventCustomerSegmentLeft` +- `EventCustomerShopifyFailed` +- `EventCustomerShopifyRecovered` +- `EventCustomerShopifySent` +- `EventCustomerSmsFailed` +- `EventCustomerSmsRecovered` +- `EventCustomerSmsSent` +- `EventCustomerUpdated` +- `EventCustomerValidationFailed` +- `EventCustomerValidationSucceeded` +- `EventCustomerVoucherDeleted` +- `EventCustomerVouchersLoyaltyPointsExpired` +- `nil` (if no type matches) + diff --git a/docs/CustomerBase.md b/docs/CustomerBase.md new file mode 100644 index 00000000..111b8c55 --- /dev/null +++ b/docs/CustomerBase.md @@ -0,0 +1,15 @@ +# VoucherifySdk::CustomerBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/CustomerBaseAddress.md b/docs/CustomerBaseAddress.md new file mode 100644 index 00000000..c46cb694 --- /dev/null +++ b/docs/CustomerBaseAddress.md @@ -0,0 +1,13 @@ +# VoucherifySdk::CustomerBaseAddress + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **city** | **String** | City | [optional] | +| **state** | **String** | State | [optional] | +| **line_1** | **String** | First line of address. | [optional] | +| **line_2** | **String** | Second line of address. | [optional] | +| **country** | **String** | Country. | [optional] | +| **postal_code** | **String** | Postal code. | [optional] | + diff --git a/docs/CustomerId.md b/docs/CustomerId.md new file mode 100644 index 00000000..d2ba73aa --- /dev/null +++ b/docs/CustomerId.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CustomerId + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier of an existing customer. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'customer'] | + diff --git a/docs/CustomerLoyalty.md b/docs/CustomerLoyalty.md new file mode 100644 index 00000000..b58c7733 --- /dev/null +++ b/docs/CustomerLoyalty.md @@ -0,0 +1,10 @@ +# VoucherifySdk::CustomerLoyalty + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Customer's loyalty points. | | +| **referred_customers** | **Integer** | Total number of customers referred by the customer. | | +| **campaigns** | [**Hash<String, CustomerLoyaltyCampaignsValue>**](CustomerLoyaltyCampaignsValue.md) | Contains campaigns with details about point balances and how many customers were referred by the customer. | | + diff --git a/docs/CustomerLoyaltyCampaignsValue.md b/docs/CustomerLoyaltyCampaignsValue.md new file mode 100644 index 00000000..0ccc7cf7 --- /dev/null +++ b/docs/CustomerLoyaltyCampaignsValue.md @@ -0,0 +1,10 @@ +# VoucherifySdk::CustomerLoyaltyCampaignsValue + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Remaining point balance in campaign. | [optional] | +| **loyalty_tier** | **String** | Customer's loyalty tier within the campaign. | [optional] | +| **referred_customers** | **Integer** | Number of customers referred by the customer in campaign. | [optional] | + diff --git a/docs/CustomerReferrals.md b/docs/CustomerReferrals.md new file mode 100644 index 00000000..d2a2774a --- /dev/null +++ b/docs/CustomerReferrals.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CustomerReferrals + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total** | **Integer** | Total number of times this customer received a referral, i.e. was referred by another customer. | | +| **campaigns** | [**Array<CustomerReferralsCampaignsItem>**](CustomerReferralsCampaignsItem.md) | Contains an array of campaigns that served as the source of a referral for the customer. | | + diff --git a/docs/CustomerReferralsCampaignsItem.md b/docs/CustomerReferralsCampaignsItem.md new file mode 100644 index 00000000..fcaa6ce5 --- /dev/null +++ b/docs/CustomerReferralsCampaignsItem.md @@ -0,0 +1,12 @@ +# VoucherifySdk::CustomerReferralsCampaignsItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **referrer_id** | **String** | Unique referrer ID, assigned by Voucherify. This is the customer ID of a customer that is referring this customer. | | +| **related_object_id** | **String** | Related object id | | +| **related_object_type** | **String** | Related object type, i.e. `redemption`. | | +| **date** | **Time** | Timestamp representing the date and time when the customer was referred in ISO 8601 format. | | + diff --git a/docs/CustomerResponseDataAssets.md b/docs/CustomerResponseDataAssets.md new file mode 100644 index 00000000..15f98b15 --- /dev/null +++ b/docs/CustomerResponseDataAssets.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CustomerResponseDataAssets + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **cockpit_url** | **String** | Customer's cockpit URL address. | [optional] | + diff --git a/docs/CustomerSegmentsList.md b/docs/CustomerSegmentsList.md new file mode 100644 index 00000000..86baeb0a --- /dev/null +++ b/docs/CustomerSegmentsList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CustomerSegmentsList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about customer segments. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of segment IDs. | [default to 'data'] | +| **data** | [**Array<SimpleSegment>**](SimpleSegment.md) | A dictionary that contains an array of segment IDs and names. | | +| **total** | **Integer** | Total number of segments the customer belongs to. | | + diff --git a/docs/CustomerSummary.md b/docs/CustomerSummary.md new file mode 100644 index 00000000..00d4cb09 --- /dev/null +++ b/docs/CustomerSummary.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CustomerSummary + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemptions** | [**CustomerSummaryRedemptions**](CustomerSummaryRedemptions.md) | | | +| **orders** | [**CustomerSummaryOrders**](CustomerSummaryOrders.md) | | | + diff --git a/docs/CustomerSummaryOrders.md b/docs/CustomerSummaryOrders.md new file mode 100644 index 00000000..ea551070 --- /dev/null +++ b/docs/CustomerSummaryOrders.md @@ -0,0 +1,12 @@ +# VoucherifySdk::CustomerSummaryOrders + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total_amount** | **Integer** | The total amount spent by the customer. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | | +| **total_count** | **Integer** | Total number of orders made by the customer. | | +| **average_amount** | **Integer** | Average amount spent on orders. `total_amount` &divide; `total_count`. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | | +| **last_order_amount** | **Integer** | Amount spent on last order. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | | +| **last_order_date** | **Time** | Timestamp representing the date and time of the customer's last order in ISO 8601 format. | [optional] | + diff --git a/docs/CustomerSummaryRedemptions.md b/docs/CustomerSummaryRedemptions.md new file mode 100644 index 00000000..88a085bb --- /dev/null +++ b/docs/CustomerSummaryRedemptions.md @@ -0,0 +1,15 @@ +# VoucherifySdk::CustomerSummaryRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total_redeemed** | **Integer** | Total number of redemptions made by the customer. | | +| **total_failed** | **Integer** | Total number of redemptions that failed. | | +| **total_succeeded** | **Integer** | Total number of redemptions that succeeded. | | +| **total_rolled_back** | **Integer** | Total number of redemptions that were rolled back for the customer. | | +| **total_rollback_failed** | **Integer** | Total number of redemption rollbacks that failed. | | +| **total_rollback_succeeded** | **Integer** | Total number of redemption rollbacks that succeeded. | | +| **gift** | [**CustomerSummaryRedemptionsGift**](CustomerSummaryRedemptionsGift.md) | | | +| **loyalty_card** | [**CustomerSummaryRedemptionsLoyaltyCard**](CustomerSummaryRedemptionsLoyaltyCard.md) | | | + diff --git a/docs/CustomerSummaryRedemptionsGift.md b/docs/CustomerSummaryRedemptionsGift.md new file mode 100644 index 00000000..4e64ca3f --- /dev/null +++ b/docs/CustomerSummaryRedemptionsGift.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CustomerSummaryRedemptionsGift + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemed_amount** | **Integer** | Total amount of gift card credits redeemed by customer. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [default to 0] | +| **amount_to_go** | **Integer** | Remaining gift card balance across all gift cards. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [default to 0] | + diff --git a/docs/CustomerSummaryRedemptionsLoyaltyCard.md b/docs/CustomerSummaryRedemptionsLoyaltyCard.md new file mode 100644 index 00000000..0bec98eb --- /dev/null +++ b/docs/CustomerSummaryRedemptionsLoyaltyCard.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CustomerSummaryRedemptionsLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemed_points** | **Integer** | Total number of loyalty points redeemed by the customer. | | +| **points_to_go** | **Integer** | Sum of remaining available point balance across all loyalty cards. | | + diff --git a/docs/CustomerWithSummaryLoyaltyReferrals.md b/docs/CustomerWithSummaryLoyaltyReferrals.md new file mode 100644 index 00000000..eb066145 --- /dev/null +++ b/docs/CustomerWithSummaryLoyaltyReferrals.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CustomerWithSummaryLoyaltyReferrals + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | +| **id** | **String** | The ID of an existing customer that will be linked to redemption in this request. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **summary** | [**CustomerSummary**](CustomerSummary.md) | | | +| **loyalty** | [**CustomerLoyalty**](CustomerLoyalty.md) | | | +| **referrals** | [**CustomerReferrals**](CustomerReferrals.md) | | | +| **system_metadata** | **Object** | Object used to store system metadata information. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the customer was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the customer was updated in ISO 8601 format. | [optional] | +| **assets** | [**CustomerResponseDataAssets**](CustomerResponseDataAssets.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'customer'] | + diff --git a/docs/CustomersActivitiesListResponseBody.md b/docs/CustomersActivitiesListResponseBody.md new file mode 100644 index 00000000..3b180dd0 --- /dev/null +++ b/docs/CustomersActivitiesListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CustomersActivitiesListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about customer activities in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of customer activity objects. | [default to 'data'] | +| **data** | [**Array<CustomerActivity>**](CustomerActivity.md) | Array of customer activity objects. | | +| **total** | **Integer** | Total number of customer activities. | | + diff --git a/docs/CustomersApi.md b/docs/CustomersApi.md new file mode 100644 index 00000000..35f4de04 --- /dev/null +++ b/docs/CustomersApi.md @@ -0,0 +1,771 @@ +# VoucherifySdk::CustomersApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_customer**](CustomersApi.md#create_customer) | **POST** /v1/customers | Create Customer | +| [**customer_permanently_deletion**](CustomersApi.md#customer_permanently_deletion) | **POST** /v1/customers/{customerId}/permanent-deletion | Delete Customer Permanently | +| [**delete_customer**](CustomersApi.md#delete_customer) | **DELETE** /v1/customers/{customerId} | Delete Customer | +| [**get_customer**](CustomersApi.md#get_customer) | **GET** /v1/customers/{customerId} | Get Customer | +| [**import_customers_using_csv**](CustomersApi.md#import_customers_using_csv) | **POST** /v1/customers/importCSV | Import and Update Customers using CSV | +| [**list_customer_activities**](CustomersApi.md#list_customer_activities) | **GET** /v1/customers/{customerId}/activities | List Customer Activities | +| [**list_customer_segments**](CustomersApi.md#list_customer_segments) | **GET** /v1/customers/{customerId}/segments | List Customer's Segments | +| [**list_customers**](CustomersApi.md#list_customers) | **GET** /v1/customers | List Customers | +| [**update_customer**](CustomersApi.md#update_customer) | **PUT** /v1/customers/{customerId} | Update Customer | +| [**update_customers_consents**](CustomersApi.md#update_customers_consents) | **PUT** /v1/customers/{customerId}/consents | Update Customer's consents | +| [**update_customers_in_bulk**](CustomersApi.md#update_customers_in_bulk) | **POST** /v1/customers/bulk/async | Update Customers in bulk | +| [**update_customers_metadata_in_bulk**](CustomersApi.md#update_customers_metadata_in_bulk) | **POST** /v1/customers/metadata/async | Update Customers' Metadata in bulk | + + +## create_customer + +> create_customer(opts) + +Create Customer + +Creates a customer object. 📘 Upsert Mode If you pass an id or a source_id that already exists in the customer database, Voucherify will return a related customer object with updated fields. + +### 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::CustomersApi.new +opts = { + customers_create_request_body: VoucherifySdk::CustomersCreateRequestBody.new # CustomersCreateRequestBody | Create a customer with specified parameters. +} + +begin + # Create Customer + result = api_instance.create_customer(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->create_customer: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customers_create_request_body** | [**CustomersCreateRequestBody**](CustomersCreateRequestBody.md) | Create a customer with specified parameters. | [optional] | + +### Return type + +[**CustomersCreateResponseBody**](CustomersCreateResponseBody.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 + + +## customer_permanently_deletion + +> customer_permanently_deletion(customer_id) + +Delete Customer Permanently + +The organization user can remove consumer data permanently from the Voucherify system by using this API method. It deletes all customer data and connected resources. It makes the customer profile forgotten by Voucherify. + +### 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::CustomersApi.new +customer_id = 'customer_id_example' # String | A Voucherify customers id or source_id. + +begin + # Delete Customer Permanently + result = api_instance.customer_permanently_deletion(customer_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->customer_permanently_deletion: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | A Voucherify customers id or source_id. | | + +### Return type + +[**CustomersPermanentDeletionCreateResponseBody**](CustomersPermanentDeletionCreateResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## delete_customer + +> delete_customer(customer_id) + +Delete Customer + +This method deletes a customer. + +### 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::CustomersApi.new +customer_id = 'customer_id_example' # String | A Voucherify customers id or source_id. + +begin + # Delete Customer + api_instance.delete_customer(customer_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->delete_customer: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | A Voucherify customers id or source_id. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## get_customer + +> get_customer(customer_id) + +Get Customer + +Retrieve customer details. + +### 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::CustomersApi.new +customer_id = 'customer_id_example' # String | A Voucherify customers id or source_id. + +begin + # Get Customer + result = api_instance.get_customer(customer_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->get_customer: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | A Voucherify customers id or source_id. | | + +### Return type + +[**CustomersGetResponseBody**](CustomersGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## import_customers_using_csv + +> import_customers_using_csv(file) + +Import and Update Customers using CSV + +This API method lets you import or update customer data. To get a proper and valid response, please send a CSV file with data separated by commas. # Request Example # CSV File Format The CSV file has to include headers in the first line. All properties which cannot be mapped to standard customer fields will be added to the metadata object. 📘 Standard customer fields mapping **No spaces allowed in field names** Id, Name, Email, Phone, Birthdate, Source_id, Address_line_1, Address_line_2, Address_Postal_Code, Address_City, Address_State, Address_Country, Description, Metadata_name_1, Metadata_name_2 # Update Customers using CSV If you would like to update customers data, you can do it using the CSV file with new data. However, remember to include a source_id in your CSV file to manage the update successfully. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::CustomersApi.new +file = File.new('/path/to/some/file') # File | File path. + +begin + # Import and Update Customers using CSV + result = api_instance.import_customers_using_csv(file) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->import_customers_using_csv: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **file** | **File** | File path. | | + +### Return type + +[**CustomersImportCsvCreateResponseBody**](CustomersImportCsvCreateResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + + +## list_customer_activities + +> list_customer_activities(customer_id, opts) + +List Customer Activities + +Retrieve customer activities. + +### 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::CustomersApi.new +customer_id = 'customer_id_example' # String | A Voucherify customers id or source ID of the customer who performed the activities. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + order: VoucherifySdk::ParameterOrder::CREATED_AT, # ParameterOrder | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + starting_after: Time.parse('2013-10-20T19:20:30+01:00'), # Time | A cursor for use in pagination. starting_after is a date-time value that defines your place in the list based on created_at property from the activity object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. + starting_after_id: 'starting_after_id_example', # String | By applying this filter value, you will get events starting after an event with the given ID. + campaign_type: VoucherifySdk::ParameterCampaignType::PROMOTION, # ParameterCampaignType | Through this parameter you can control a type of campaign by which Voucherify will filter related customers activity. API will return only records related to that given type. Allowed values: DISCOUNT_COUPONS, REFERRAL_PROGRAM, GIFT_VOUCHERS, PROMOTION, LOYALTY_PROGRAM + campaign_id: 'campaign_id_example', # String | By applying this parameter you request only events related to specific campaign identified by its ID. + product_id: 'product_id_example', # String | By applying this parameter you request only events related to specific product identified by its ID. + start_date: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + end_date: Time.parse('2013-10-20T19:20:30+01:00') # Time | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. +} + +begin + # List Customer Activities + result = api_instance.list_customer_activities(customer_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->list_customer_activities: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | A Voucherify customers id or source ID of the customer who performed the activities. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **order** | [**ParameterOrder**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **starting_after** | **Time** | A cursor for use in pagination. starting_after is a date-time value that defines your place in the list based on created_at property from the activity object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. | [optional] | +| **starting_after_id** | **String** | By applying this filter value, you will get events starting after an event with the given ID. | [optional] | +| **campaign_type** | [**ParameterCampaignType**](.md) | Through this parameter you can control a type of campaign by which Voucherify will filter related customers activity. API will return only records related to that given type. Allowed values: DISCOUNT_COUPONS, REFERRAL_PROGRAM, GIFT_VOUCHERS, PROMOTION, LOYALTY_PROGRAM | [optional] | +| **campaign_id** | **String** | By applying this parameter you request only events related to specific campaign identified by its ID. | [optional] | +| **product_id** | **String** | By applying this parameter you request only events related to specific product identified by its ID. | [optional] | +| **start_date** | **Time** | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. | [optional] | +| **end_date** | **Time** | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. | [optional] | + +### Return type + +[**CustomersActivitiesListResponseBody**](CustomersActivitiesListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_customer_segments + +> list_customer_segments(customer_id) + +List Customer's Segments + +Returns the list of segments IDs to which the customer belongs to. If you pass a customerId which is not stored and recognized by Voucherify as an existing customer in the system, the response will generate a list of segments that the customer would potentialy qualify for if they were to become a customer tracked in the system. + +### 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::CustomersApi.new +customer_id = 'customer_id_example' # String | Unique identifier of a customer represented by an internal customer ID or customer source ID. + +begin + # List Customer's Segments + result = api_instance.list_customer_segments(customer_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->list_customer_segments: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | Unique identifier of a customer represented by an internal customer ID or customer source ID. | | + +### Return type + +[**CustomersSegmentsListResponseBody**](CustomersSegmentsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_customers + +> list_customers(opts) + +List Customers + +Returns a list of customers. + +### 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::CustomersApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + email: 'email_example', # String | Limit the customers to the ones that have this specific email address. + city: 'city_example', # String | Limit the customers to the ones that are located in the specified city. + name: 'name_example', # String | Filter customers by the name property. + segment_id: 'segment_id_example', # String | Filter customers by the segment id. + created_at_before: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Filter customers by date customer was created. + created_at_after: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Filter customers by date customer was created. + updated_at_before: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Filter customers by date customer was updated last time. + updated_at_after: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Filter customers by date customer was updated last time. + order: VoucherifySdk::ParameterOrderListCustomers::CREATED_AT, # ParameterOrderListCustomers | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + starting_after: Time.parse('2013-10-20T19:20:30+01:00') # Time | A cursor for use in pagination. This is a date-time value that defines your place in the list based on created_at property from the customer object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. +} + +begin + # List Customers + result = api_instance.list_customers(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->list_customers: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **email** | **String** | Limit the customers to the ones that have this specific email address. | [optional] | +| **city** | **String** | Limit the customers to the ones that are located in the specified city. | [optional] | +| **name** | **String** | Filter customers by the name property. | [optional] | +| **segment_id** | **String** | Filter customers by the segment id. | [optional] | +| **created_at_before** | **Time** | Filter customers by date customer was created. | [optional] | +| **created_at_after** | **Time** | Filter customers by date customer was created. | [optional] | +| **updated_at_before** | **Time** | Filter customers by date customer was updated last time. | [optional] | +| **updated_at_after** | **Time** | Filter customers by date customer was updated last time. | [optional] | +| **order** | [**ParameterOrderListCustomers**](.md) | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **starting_after** | **Time** | A cursor for use in pagination. This is a date-time value that defines your place in the list based on created_at property from the customer object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. | [optional] | + +### Return type + +[**CustomersListResponseBody**](CustomersListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_customer + +> update_customer(customer_id, opts) + +Update Customer + +Updates the specified customer by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. + +### 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::CustomersApi.new +customer_id = 'customer_id_example' # String | A Voucherify customers id or source_id. +opts = { + customers_update_request_body: VoucherifySdk::CustomersUpdateRequestBody.new # CustomersUpdateRequestBody | Specify the parameters to be updated. +} + +begin + # Update Customer + result = api_instance.update_customer(customer_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->update_customer: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | A Voucherify customers id or source_id. | | +| **customers_update_request_body** | [**CustomersUpdateRequestBody**](CustomersUpdateRequestBody.md) | Specify the parameters to be updated. | [optional] | + +### Return type + +[**CustomersUpdateResponseBody**](CustomersUpdateResponseBody.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 + + +## update_customers_consents + +> update_customers_consents(customer_id, opts) + +Update Customer's consents + +Update marketing permissions for the specified customer. + +### 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::CustomersApi.new +customer_id = 'customer_id_example' # String | A Voucherify unique customer identifier or source ID. +opts = { + body: { ... } # Object | Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: +} + +begin + # Update Customer's consents + api_instance.update_customers_consents(customer_id, opts) +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->update_customers_consents: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | A Voucherify unique customer identifier or source ID. | | +| **body** | **Object** | Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: | [optional] | + +### Return type + +nil (empty response body) + +### 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**: Not defined + + +## update_customers_in_bulk + +> update_customers_in_bulk(opts) + +Update Customers in bulk + +Update several customers in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested customer object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::CustomersApi.new +opts = { + customers_update_in_bulk_request_body: [VoucherifySdk::CustomersUpdateInBulkRequestBody.new({source_id: 'source_id_example'})] # Array | Specify the customer fields that you would like to update in each customer object. +} + +begin + # Update Customers in bulk + result = api_instance.update_customers_in_bulk(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->update_customers_in_bulk: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customers_update_in_bulk_request_body** | [**Array<CustomersUpdateInBulkRequestBody>**](CustomersUpdateInBulkRequestBody.md) | Specify the customer fields that you would like to update in each customer object. | [optional] | + +### Return type + +[**CustomersUpdateInBulkResponseBody**](CustomersUpdateInBulkResponseBody.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 + + +## update_customers_metadata_in_bulk + +> update_customers_metadata_in_bulk(opts) + +Update Customers' Metadata in bulk + +Update several customers metadata properties in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested customer object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::CustomersApi.new +opts = { + customers_metadata_update_in_bulk_request_body: VoucherifySdk::CustomersMetadataUpdateInBulkRequestBody.new({source_ids: ['source_ids_example'], metadata: 3.56}) # CustomersMetadataUpdateInBulkRequestBody | List the source_ids of the customers you would like to update along with the metadata key value pairs. +} + +begin + # Update Customers' Metadata in bulk + result = api_instance.update_customers_metadata_in_bulk(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling CustomersApi->update_customers_metadata_in_bulk: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customers_metadata_update_in_bulk_request_body** | [**CustomersMetadataUpdateInBulkRequestBody**](CustomersMetadataUpdateInBulkRequestBody.md) | List the source_ids of the customers you would like to update along with the metadata key value pairs. | [optional] | + +### Return type + +[**CustomersMetadataUpdateInBulkResponseBody**](CustomersMetadataUpdateInBulkResponseBody.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 + diff --git a/docs/CustomersCreateRequestBody.md b/docs/CustomersCreateRequestBody.md new file mode 100644 index 00000000..648f557a --- /dev/null +++ b/docs/CustomersCreateRequestBody.md @@ -0,0 +1,17 @@ +# VoucherifySdk::CustomersCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The ID of an existing customer. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/CustomersCreateResponseBody.md b/docs/CustomersCreateResponseBody.md new file mode 100644 index 00000000..7a78518e --- /dev/null +++ b/docs/CustomersCreateResponseBody.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CustomersCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The ID of an existing customer that will be linked to redemption in this request. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **summary** | [**CustomerSummary**](CustomerSummary.md) | | | +| **loyalty** | [**CustomerLoyalty**](CustomerLoyalty.md) | | | +| **referrals** | [**CustomerReferrals**](CustomerReferrals.md) | | | +| **system_metadata** | **Object** | Object used to store system metadata information. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the customer was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the customer was updated in ISO 8601 format. | [optional] | +| **assets** | [**CustomerResponseDataAssets**](CustomerResponseDataAssets.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'customer'] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/CustomersGetResponseBody.md b/docs/CustomersGetResponseBody.md new file mode 100644 index 00000000..47b196f2 --- /dev/null +++ b/docs/CustomersGetResponseBody.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CustomersGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The ID of an existing customer that will be linked to redemption in this request. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **summary** | [**CustomerSummary**](CustomerSummary.md) | | | +| **loyalty** | [**CustomerLoyalty**](CustomerLoyalty.md) | | | +| **referrals** | [**CustomerReferrals**](CustomerReferrals.md) | | | +| **system_metadata** | **Object** | Object used to store system metadata information. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the customer was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the customer was updated in ISO 8601 format. | [optional] | +| **assets** | [**CustomerResponseDataAssets**](CustomerResponseDataAssets.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'customer'] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/CustomersImportCsvCreateResponseBody.md b/docs/CustomersImportCsvCreateResponseBody.md new file mode 100644 index 00000000..971a0317 --- /dev/null +++ b/docs/CustomersImportCsvCreateResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CustomersImportCsvCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/CustomersListResponseBody.md b/docs/CustomersListResponseBody.md new file mode 100644 index 00000000..9312a8a3 --- /dev/null +++ b/docs/CustomersListResponseBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::CustomersListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about customers in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of customer objects. | [default to 'customers'] | +| **customers** | [**Array<CustomerWithSummaryLoyaltyReferrals>**](CustomerWithSummaryLoyaltyReferrals.md) | Contains array of customer objects. | | +| **total** | **Integer** | Total number of customers. | | +| **has_more** | **Boolean** | As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different end date filter) to get more records returned in the results. | [optional] | + diff --git a/docs/CustomersMetadataUpdateInBulkRequestBody.md b/docs/CustomersMetadataUpdateInBulkRequestBody.md new file mode 100644 index 00000000..aeb417a7 --- /dev/null +++ b/docs/CustomersMetadataUpdateInBulkRequestBody.md @@ -0,0 +1,9 @@ +# VoucherifySdk::CustomersMetadataUpdateInBulkRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **source_ids** | **Array<String>** | An array of customer `source_id`'s. | | +| **metadata** | **Object** | Metadata key value pairs to be updated. A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | | + diff --git a/docs/CustomersMetadataUpdateInBulkResponseBody.md b/docs/CustomersMetadataUpdateInBulkResponseBody.md new file mode 100644 index 00000000..c48edd9a --- /dev/null +++ b/docs/CustomersMetadataUpdateInBulkResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CustomersMetadataUpdateInBulkResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/CustomersPermanentDeletionCreateResponseBody.md b/docs/CustomersPermanentDeletionCreateResponseBody.md new file mode 100644 index 00000000..d437c576 --- /dev/null +++ b/docs/CustomersPermanentDeletionCreateResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::CustomersPermanentDeletionCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique permanent deletion object ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the customer was requested to be deleted in ISO 8601 format. | | +| **related_object_id** | **String** | Unique customer ID that is being deleted. | | +| **related_object** | **String** | Object being deleted. | [default to 'customer'] | +| **status** | **String** | Deletion status. | [default to 'DONE'] | +| **data_json** | [**CustomersPermanentDeletionCreateResponseBodyDataJson**](CustomersPermanentDeletionCreateResponseBodyDataJson.md) | | | +| **object** | **String** | The type of object represented by JSON. | [default to 'pernament_deletion'] | + diff --git a/docs/CustomersPermanentDeletionCreateResponseBodyDataJson.md b/docs/CustomersPermanentDeletionCreateResponseBodyDataJson.md new file mode 100644 index 00000000..218782a0 --- /dev/null +++ b/docs/CustomersPermanentDeletionCreateResponseBodyDataJson.md @@ -0,0 +1,14 @@ +# VoucherifySdk::CustomersPermanentDeletionCreateResponseBodyDataJson + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **events** | **Integer** | Number of events deleted. | | +| **customer_events** | **Integer** | Number of customer events deleted. | | +| **daily_events** | **Integer** | Number of daily events deleted. | | +| **segments** | **Integer** | Number of segments deleted. | | +| **orders** | **Integer** | Number of orders deleted. | | +| **order_events** | **Integer** | Number of order events deleted. | | +| **customer** | **Integer** | Number of customers deleted. | [default to 1] | + diff --git a/docs/CustomersSegmentsListResponseBody.md b/docs/CustomersSegmentsListResponseBody.md new file mode 100644 index 00000000..b0bfa96e --- /dev/null +++ b/docs/CustomersSegmentsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::CustomersSegmentsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about customer segments. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of segment IDs. | [default to 'data'] | +| **data** | [**Array<SimpleSegment>**](SimpleSegment.md) | A dictionary that contains an array of segment IDs and names. | | +| **total** | **Integer** | Total number of segments the customer belongs to. | | + diff --git a/docs/CustomersUpdateInBulkRequestBody.md b/docs/CustomersUpdateInBulkRequestBody.md new file mode 100644 index 00000000..ed2aa3ca --- /dev/null +++ b/docs/CustomersUpdateInBulkRequestBody.md @@ -0,0 +1,16 @@ +# VoucherifySdk::CustomersUpdateInBulkRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | +| **source_id** | **String** | Unique customer source ID. | | + diff --git a/docs/CustomersUpdateInBulkResponseBody.md b/docs/CustomersUpdateInBulkResponseBody.md new file mode 100644 index 00000000..1e4ac2c2 --- /dev/null +++ b/docs/CustomersUpdateInBulkResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::CustomersUpdateInBulkResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/CustomersUpdateRequestBody.md b/docs/CustomersUpdateRequestBody.md new file mode 100644 index 00000000..e354dbd3 --- /dev/null +++ b/docs/CustomersUpdateRequestBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::CustomersUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/CustomersUpdateResponseBody.md b/docs/CustomersUpdateResponseBody.md new file mode 100644 index 00000000..10d44a53 --- /dev/null +++ b/docs/CustomersUpdateResponseBody.md @@ -0,0 +1,25 @@ +# VoucherifySdk::CustomersUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The ID of an existing customer that will be linked to redemption in this request. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **summary** | [**CustomerSummary**](CustomerSummary.md) | | | +| **loyalty** | [**CustomerLoyalty**](CustomerLoyalty.md) | | | +| **referrals** | [**CustomerReferrals**](CustomerReferrals.md) | | | +| **system_metadata** | **Object** | Object used to store system metadata information. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the customer was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the customer was updated in ISO 8601 format. | [optional] | +| **assets** | [**CustomerResponseDataAssets**](CustomerResponseDataAssets.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'customer'] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/Discount.md b/docs/Discount.md new file mode 100644 index 00000000..2bd44e31 --- /dev/null +++ b/docs/Discount.md @@ -0,0 +1,55 @@ +# VoucherifySdk::Discount + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::Discount.openapi_one_of +# => +# [ +# :'DiscountAmount', +# :'DiscountFixed', +# :'DiscountPercent', +# :'DiscountUnit', +# :'DiscountUnitMultiple' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::Discount.build(data) +# => # + +VoucherifySdk::Discount.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `DiscountAmount` +- `DiscountFixed` +- `DiscountPercent` +- `DiscountUnit` +- `DiscountUnitMultiple` +- `nil` (if no type matches) + diff --git a/docs/DiscountAmount.md b/docs/DiscountAmount.md new file mode 100644 index 00000000..450e6243 --- /dev/null +++ b/docs/DiscountAmount.md @@ -0,0 +1,13 @@ +# VoucherifySdk::DiscountAmount + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines the type of the voucher. | [default to 'AMOUNT'] | +| **amount_off** | **Float** | Amount taken off the subtotal of a price. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 discount is written as 1000. | | +| **amount_off_formula** | **String** | | [optional] | +| **aggregated_amount_limit** | **Integer** | Maximum discount amount per order. | [optional] | +| **effect** | [**DiscountAmountVouchersEffectTypes**](DiscountAmountVouchersEffectTypes.md) | | [optional] | +| **is_dynamic** | **Boolean** | Flag indicating whether the discount was calculated using a formula. | [optional] | + diff --git a/docs/DiscountAmountVouchersEffectTypes.md b/docs/DiscountAmountVouchersEffectTypes.md new file mode 100644 index 00000000..dcc61513 --- /dev/null +++ b/docs/DiscountAmountVouchersEffectTypes.md @@ -0,0 +1,7 @@ +# VoucherifySdk::DiscountAmountVouchersEffectTypes + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/DiscountCouponsCampaignVoucher.md b/docs/DiscountCouponsCampaignVoucher.md new file mode 100644 index 00000000..444d7dba --- /dev/null +++ b/docs/DiscountCouponsCampaignVoucher.md @@ -0,0 +1,11 @@ +# VoucherifySdk::DiscountCouponsCampaignVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of voucher. | [default to 'DISCOUNT_VOUCHER'] | +| **discount** | [**Discount**](Discount.md) | | | +| **code_config** | [**CodeConfig**](CodeConfig.md) | | [optional] | +| **redemption** | [**CampaignLoyaltyVoucherRedemption**](CampaignLoyaltyVoucherRedemption.md) | | [optional] | + diff --git a/docs/DiscountFixed.md b/docs/DiscountFixed.md new file mode 100644 index 00000000..9db5b6c6 --- /dev/null +++ b/docs/DiscountFixed.md @@ -0,0 +1,12 @@ +# VoucherifySdk::DiscountFixed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines the type of the voucher. | [default to 'FIXED'] | +| **fixed_amount** | **Float** | Sets a fixed value for an order total or the item price. The value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 discount is written as 1000. If the fixed amount is calculated by the formula, i.e. the `fixed_amount_formula` parameter is present in the fixed amount definition, this value becomes the **fallback value**. As a result, if the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed value. | | +| **fixed_amount_formula** | **String** | | [optional] | +| **effect** | [**DiscountFixedVouchersEffectTypes**](DiscountFixedVouchersEffectTypes.md) | | [optional] | +| **is_dynamic** | **Boolean** | Flag indicating whether the discount was calculated using a formula. | [optional] | + diff --git a/docs/DiscountFixedVouchersEffectTypes.md b/docs/DiscountFixedVouchersEffectTypes.md new file mode 100644 index 00000000..3f2d8cb4 --- /dev/null +++ b/docs/DiscountFixedVouchersEffectTypes.md @@ -0,0 +1,7 @@ +# VoucherifySdk::DiscountFixedVouchersEffectTypes + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/DiscountPercent.md b/docs/DiscountPercent.md new file mode 100644 index 00000000..33fb17a1 --- /dev/null +++ b/docs/DiscountPercent.md @@ -0,0 +1,14 @@ +# VoucherifySdk::DiscountPercent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines the type of the voucher. | [default to 'PERCENT'] | +| **percent_off** | **Float** | The percent discount that the customer will receive. | | +| **percent_off_formula** | **String** | | [optional] | +| **amount_limit** | **Float** | Upper limit allowed to be applied as a discount. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600. | [optional] | +| **aggregated_amount_limit** | **Integer** | Maximum discount amount per order. | [optional] | +| **effect** | [**DiscountPercentVouchersEffectTypes**](DiscountPercentVouchersEffectTypes.md) | | [optional] | +| **is_dynamic** | **Boolean** | Flag indicating whether the discount was calculated using a formula. | [optional] | + diff --git a/docs/DiscountPercentVouchersEffectTypes.md b/docs/DiscountPercentVouchersEffectTypes.md new file mode 100644 index 00000000..89bcf736 --- /dev/null +++ b/docs/DiscountPercentVouchersEffectTypes.md @@ -0,0 +1,7 @@ +# VoucherifySdk::DiscountPercentVouchersEffectTypes + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/DiscountUnit.md b/docs/DiscountUnit.md new file mode 100644 index 00000000..068c270b --- /dev/null +++ b/docs/DiscountUnit.md @@ -0,0 +1,15 @@ +# VoucherifySdk::DiscountUnit + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Discount type. | [default to 'UNIT'] | +| **unit_off** | **Integer** | Number of units to be granted a full value discount. | [optional] | +| **unit_off_formula** | **String** | | [optional] | +| **effect** | [**DiscountUnitVouchersEffectTypes**](DiscountUnitVouchersEffectTypes.md) | | [optional] | +| **unit_type** | **String** | The product deemed as free, chosen from product inventory (e.g. time, items). | | +| **product** | [**SimpleProductDiscountUnit**](SimpleProductDiscountUnit.md) | | [optional] | +| **sku** | [**SimpleSkuDiscountUnit**](SimpleSkuDiscountUnit.md) | | [optional] | +| **is_dynamic** | **Boolean** | Flag indicating whether the discount was calculated using a formula. | [optional] | + diff --git a/docs/DiscountUnitMultiple.md b/docs/DiscountUnitMultiple.md new file mode 100644 index 00000000..27b0dbe5 --- /dev/null +++ b/docs/DiscountUnitMultiple.md @@ -0,0 +1,10 @@ +# VoucherifySdk::DiscountUnitMultiple + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Discount type. | [default to 'UNIT'] | +| **effect** | **String** | Defines how the discount is applied to the customer's order. | [optional][default to 'ADD_MANY_ITEMS'] | +| **units** | [**Array<DiscountUnitMultipleOneUnit>**](DiscountUnitMultipleOneUnit.md) | | | + diff --git a/docs/DiscountUnitMultipleOneUnit.md b/docs/DiscountUnitMultipleOneUnit.md new file mode 100644 index 00000000..c73ead3e --- /dev/null +++ b/docs/DiscountUnitMultipleOneUnit.md @@ -0,0 +1,13 @@ +# VoucherifySdk::DiscountUnitMultipleOneUnit + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **unit_off** | **Float** | Number of units to be granted a full value discount. | [optional] | +| **unit_off_formula** | **String** | | [optional] | +| **effect** | **String** | Defines how the unit is added to the customer's order. | | +| **unit_type** | **String** | The product deemed as free, chosen from product inventory (e.g. time, items). | | +| **product** | [**SimpleProductDiscountUnit**](SimpleProductDiscountUnit.md) | | [optional] | +| **sku** | [**SimpleSkuDiscountUnit**](SimpleSkuDiscountUnit.md) | | [optional] | + diff --git a/docs/DiscountUnitVouchersEffectTypes.md b/docs/DiscountUnitVouchersEffectTypes.md new file mode 100644 index 00000000..05853d10 --- /dev/null +++ b/docs/DiscountUnitVouchersEffectTypes.md @@ -0,0 +1,7 @@ +# VoucherifySdk::DiscountUnitVouchersEffectTypes + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/EarningRule.md b/docs/EarningRule.md new file mode 100644 index 00000000..b1b47d33 --- /dev/null +++ b/docs/EarningRule.md @@ -0,0 +1,24 @@ +# VoucherifySdk::EarningRule + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the earning rule object. | | +| **created_at** | **Time** | Timestamp representing the date and time when the earning rule was created in ISO 8601 format. | | +| **loyalty** | [**EarningRuleBaseLoyalty**](EarningRuleBaseLoyalty.md) | | | +| **event** | [**EarningRuleEvent**](EarningRuleEvent.md) | | [optional] | +| **custom_event** | [**EarningRuleBaseCustomEvent**](EarningRuleBaseCustomEvent.md) | | [optional] | +| **segment** | [**EarningRuleBaseSegment**](EarningRuleBaseSegment.md) | | [optional] | +| **source** | [**EarningRuleBaseSource**](EarningRuleBaseSource.md) | | | +| **object** | **String** | The type of object represented by JSON. Default is earning_rule. | [default to 'earning_rule'] | +| **automation_id** | **String** | For internal use by Voucherify. | | +| **start_date** | **String** | Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. | [optional] | +| **expiration_date** | **String** | Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. | [optional] | +| **validity_timeframe** | [**EarningRuleBaseValidityTimeframe**](EarningRuleBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. | | +| **validation_rule_id** | **String** | A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. | | +| **active** | **Boolean** | A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. - `true` indicates an active earning rule - `false` indicates an inactive earning rule | | + diff --git a/docs/EarningRuleBase.md b/docs/EarningRuleBase.md new file mode 100644 index 00000000..65180f48 --- /dev/null +++ b/docs/EarningRuleBase.md @@ -0,0 +1,21 @@ +# VoucherifySdk::EarningRuleBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the earning rule object. | | +| **created_at** | **Time** | Timestamp representing the date and time when the earning rule was created in ISO 8601 format. | | +| **loyalty** | [**EarningRuleBaseLoyalty**](EarningRuleBaseLoyalty.md) | | | +| **event** | [**EarningRuleEvent**](EarningRuleEvent.md) | | [optional] | +| **custom_event** | [**EarningRuleBaseCustomEvent**](EarningRuleBaseCustomEvent.md) | | [optional] | +| **segment** | [**EarningRuleBaseSegment**](EarningRuleBaseSegment.md) | | [optional] | +| **source** | [**EarningRuleBaseSource**](EarningRuleBaseSource.md) | | | +| **object** | **String** | The type of object represented by JSON. Default is earning_rule. | [default to 'earning_rule'] | +| **automation_id** | **String** | For internal use by Voucherify. | | +| **start_date** | **String** | Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. | [optional] | +| **expiration_date** | **String** | Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. | [optional] | +| **validity_timeframe** | [**EarningRuleBaseValidityTimeframe**](EarningRuleBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. | | + diff --git a/docs/EarningRuleBaseCustomEvent.md b/docs/EarningRuleBaseCustomEvent.md new file mode 100644 index 00000000..19617a9b --- /dev/null +++ b/docs/EarningRuleBaseCustomEvent.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleBaseCustomEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **schema_id** | **String** | | | + diff --git a/docs/EarningRuleBaseLoyalty.md b/docs/EarningRuleBaseLoyalty.md new file mode 100644 index 00000000..24149fc4 --- /dev/null +++ b/docs/EarningRuleBaseLoyalty.md @@ -0,0 +1,49 @@ +# VoucherifySdk::EarningRuleBaseLoyalty + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleBaseLoyalty.openapi_one_of +# => +# [ +# :'EarningRuleFixed', +# :'EarningRuleProportional' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleBaseLoyalty.build(data) +# => # + +VoucherifySdk::EarningRuleBaseLoyalty.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `EarningRuleFixed` +- `EarningRuleProportional` +- `nil` (if no type matches) + diff --git a/docs/EarningRuleBaseSegment.md b/docs/EarningRuleBaseSegment.md new file mode 100644 index 00000000..6287d6f8 --- /dev/null +++ b/docs/EarningRuleBaseSegment.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleBaseSegment + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Contains a unique identifier of a customer segment. Assigned by the Voucherify API. | | + diff --git a/docs/EarningRuleBaseSource.md b/docs/EarningRuleBaseSource.md new file mode 100644 index 00000000..36907030 --- /dev/null +++ b/docs/EarningRuleBaseSource.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleBaseSource + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **banner** | **String** | Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. | [optional] | +| **object_id** | **String** | A unique campaign identifier assigned by the Voucherify API. | | +| **object_type** | **String** | Defines the object associated with the earning rule. Defaults to `campaign`. | [default to 'campaign'] | + diff --git a/docs/EarningRuleBaseValidityTimeframe.md b/docs/EarningRuleBaseValidityTimeframe.md new file mode 100644 index 00000000..cc74e116 --- /dev/null +++ b/docs/EarningRuleBaseValidityTimeframe.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EarningRuleBaseValidityTimeframe + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **duration** | **String** | Defines the amount of time an earning rule will be active in ISO 8601 format. For example, an earning rule with a duration of PT1H will be valid for a duration of one hour. | | +| **interval** | **String** | Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, an earning rule with an interval of P2D will be valid every other day. | | + diff --git a/docs/EarningRuleEvent.md b/docs/EarningRuleEvent.md new file mode 100644 index 00000000..eabe317c --- /dev/null +++ b/docs/EarningRuleEvent.md @@ -0,0 +1,7 @@ +# VoucherifySdk::EarningRuleEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/EarningRuleFixed.md b/docs/EarningRuleFixed.md new file mode 100644 index 00000000..52cb7a39 --- /dev/null +++ b/docs/EarningRuleFixed.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EarningRuleFixed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | The number of points to be added to the loyalty card. | [optional][default to 'FIXED'] | +| **points** | **Integer** | Defines how the points will be added to the loyalty card. FIXED adds a fixed number of points. | [optional] | + diff --git a/docs/EarningRuleProportional.md b/docs/EarningRuleProportional.md new file mode 100644 index 00000000..3a78cbb8 --- /dev/null +++ b/docs/EarningRuleProportional.md @@ -0,0 +1,53 @@ +# VoucherifySdk::EarningRuleProportional + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleProportional.openapi_one_of +# => +# [ +# :'EarningRuleProportionalCustomEvent', +# :'EarningRuleProportionalCustomerMetadata', +# :'EarningRuleProportionalOrder', +# :'EarningRuleProportionalOrderItems' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleProportional.build(data) +# => # + +VoucherifySdk::EarningRuleProportional.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `EarningRuleProportionalCustomEvent` +- `EarningRuleProportionalCustomerMetadata` +- `EarningRuleProportionalOrder` +- `EarningRuleProportionalOrderItems` +- `nil` (if no type matches) + diff --git a/docs/EarningRuleProportionalCustomEvent.md b/docs/EarningRuleProportionalCustomEvent.md new file mode 100644 index 00000000..b2570b4a --- /dev/null +++ b/docs/EarningRuleProportionalCustomEvent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalCustomEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | CUSTOM_EVENT_METADATA: Custom event metadata (X points for every Y in metadata attribute). | [default to 'CUSTOM_EVENT_METADATA'] | +| **custom_event** | [**EarningRuleProportionalCustomEventCustomEvent**](EarningRuleProportionalCustomEventCustomEvent.md) | | | + diff --git a/docs/EarningRuleProportionalCustomEventCustomEvent.md b/docs/EarningRuleProportionalCustomEventCustomEvent.md new file mode 100644 index 00000000..51ad1f1b --- /dev/null +++ b/docs/EarningRuleProportionalCustomEventCustomEvent.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalCustomEventCustomEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **metadata** | [**EarningRuleProportionalCustomEventCustomEventMetadata**](EarningRuleProportionalCustomEventCustomEventMetadata.md) | | | + diff --git a/docs/EarningRuleProportionalCustomEventCustomEventMetadata.md b/docs/EarningRuleProportionalCustomEventCustomEventMetadata.md new file mode 100644 index 00000000..b3fc786a --- /dev/null +++ b/docs/EarningRuleProportionalCustomEventCustomEventMetadata.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalCustomEventCustomEventMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **every** | **Integer** | For how many increments of the customer metadata property to grant points for. | | +| **points** | **Integer** | Number of points to be awarded, i.e. how many points to be added to the loyalty card. | | +| **property** | **String** | Custom event metadata property. | | + diff --git a/docs/EarningRuleProportionalCustomerMetadata.md b/docs/EarningRuleProportionalCustomerMetadata.md new file mode 100644 index 00000000..7d8a3355 --- /dev/null +++ b/docs/EarningRuleProportionalCustomerMetadata.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalCustomerMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | CUSTOMER_METADATA: Customer Metadata (X points for every Y in metadata attribute, defined in the property key under the customer.metadata object) | [default to 'CUSTOMER_METADATA'] | +| **customer** | [**EarningRuleProportionalCustomerMetadataCustomer**](EarningRuleProportionalCustomerMetadataCustomer.md) | | | + diff --git a/docs/EarningRuleProportionalCustomerMetadataCustomer.md b/docs/EarningRuleProportionalCustomerMetadataCustomer.md new file mode 100644 index 00000000..074e5632 --- /dev/null +++ b/docs/EarningRuleProportionalCustomerMetadataCustomer.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomer + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **metadata** | [**EarningRuleProportionalCustomerMetadataCustomerMetadata**](EarningRuleProportionalCustomerMetadataCustomerMetadata.md) | | | + diff --git a/docs/EarningRuleProportionalCustomerMetadataCustomerMetadata.md b/docs/EarningRuleProportionalCustomerMetadataCustomerMetadata.md new file mode 100644 index 00000000..4dcdbe68 --- /dev/null +++ b/docs/EarningRuleProportionalCustomerMetadataCustomerMetadata.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomerMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **every** | **Integer** | For how many increments of the customer metadata property to grant points for. | | +| **points** | **Integer** | Number of points to be awarded, i.e. how many points to be added to the loyalty card. | | +| **property** | **String** | Customer metadata property. | | + diff --git a/docs/EarningRuleProportionalOrder.md b/docs/EarningRuleProportionalOrder.md new file mode 100644 index 00000000..b78118b8 --- /dev/null +++ b/docs/EarningRuleProportionalOrder.md @@ -0,0 +1,51 @@ +# VoucherifySdk::EarningRuleProportionalOrder + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleProportionalOrder.openapi_one_of +# => +# [ +# :'EarningRuleProportionalOrderAmount', +# :'EarningRuleProportionalOrderMetadata', +# :'EarningRuleProportionalOrderTotalAmount' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleProportionalOrder.build(data) +# => # + +VoucherifySdk::EarningRuleProportionalOrder.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `EarningRuleProportionalOrderAmount` +- `EarningRuleProportionalOrderMetadata` +- `EarningRuleProportionalOrderTotalAmount` +- `nil` (if no type matches) + diff --git a/docs/EarningRuleProportionalOrderAmount.md b/docs/EarningRuleProportionalOrderAmount.md new file mode 100644 index 00000000..fc9b0665 --- /dev/null +++ b/docs/EarningRuleProportionalOrderAmount.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalOrderAmount + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | `ORDER_AMOUNT`: Pre-discount order amount (X points for every Y spent excluding discounts) | [default to 'ORDER_AMOUNT'] | +| **order** | [**EarningRuleProportionalOrderAmountOrder**](EarningRuleProportionalOrderAmountOrder.md) | | | + diff --git a/docs/EarningRuleProportionalOrderAmountOrder.md b/docs/EarningRuleProportionalOrderAmountOrder.md new file mode 100644 index 00000000..c68fc7f6 --- /dev/null +++ b/docs/EarningRuleProportionalOrderAmountOrder.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalOrderAmountOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **amount** | [**EarningRuleProportionalOrderAmountOrderAmount**](EarningRuleProportionalOrderAmountOrderAmount.md) | | | + diff --git a/docs/EarningRuleProportionalOrderAmountOrderAmount.md b/docs/EarningRuleProportionalOrderAmountOrderAmount.md new file mode 100644 index 00000000..2443509b --- /dev/null +++ b/docs/EarningRuleProportionalOrderAmountOrderAmount.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EarningRuleProportionalOrderAmountOrderAmount + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **every** | **Integer** | Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 order amount is written as 1000. | | +| **points** | **Integer** | Number of points to be awarded, i.e. how many points to be added to the loyalty card. | | + diff --git a/docs/EarningRuleProportionalOrderItems.md b/docs/EarningRuleProportionalOrderItems.md new file mode 100644 index 00000000..fb9a1eaa --- /dev/null +++ b/docs/EarningRuleProportionalOrderItems.md @@ -0,0 +1,51 @@ +# VoucherifySdk::EarningRuleProportionalOrderItems + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleProportionalOrderItems.openapi_one_of +# => +# [ +# :'EarningRuleProportionalOrderItemsAmount', +# :'EarningRuleProportionalOrderItemsQuantity', +# :'EarningRuleProportionalOrderItemsSubtotalAmount' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::EarningRuleProportionalOrderItems.build(data) +# => # + +VoucherifySdk::EarningRuleProportionalOrderItems.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `EarningRuleProportionalOrderItemsAmount` +- `EarningRuleProportionalOrderItemsQuantity` +- `EarningRuleProportionalOrderItemsSubtotalAmount` +- `nil` (if no type matches) + diff --git a/docs/EarningRuleProportionalOrderItemsAmount.md b/docs/EarningRuleProportionalOrderItemsAmount.md new file mode 100644 index 00000000..267651f3 --- /dev/null +++ b/docs/EarningRuleProportionalOrderItemsAmount.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalOrderItemsAmount + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | ORDER_ITEMS_AMOUNT; Pre-discount amount spent on items defined in the order_items.amount.object & .id (X points for every Y spent on items excluding discounts) | [default to 'ORDER_ITEMS_AMOUNT'] | +| **order_items** | [**EarningRuleProportionalOrderItemsAmountOrderItems**](EarningRuleProportionalOrderItemsAmountOrderItems.md) | | | + diff --git a/docs/EarningRuleProportionalOrderItemsAmountOrderItems.md b/docs/EarningRuleProportionalOrderItemsAmountOrderItems.md new file mode 100644 index 00000000..8847c249 --- /dev/null +++ b/docs/EarningRuleProportionalOrderItemsAmountOrderItems.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItems + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **amount** | [**EarningRuleProportionalOrderItemsAmountOrderItemsAmount**](EarningRuleProportionalOrderItemsAmountOrderItemsAmount.md) | | | + diff --git a/docs/EarningRuleProportionalOrderItemsAmountOrderItemsAmount.md b/docs/EarningRuleProportionalOrderItemsAmountOrderItemsAmount.md new file mode 100644 index 00000000..96d13b1a --- /dev/null +++ b/docs/EarningRuleProportionalOrderItemsAmountOrderItemsAmount.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItemsAmount + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **every** | **Integer** | Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 order amount is written as 1000. | | +| **points** | **Integer** | Number of points to be awarded, i.e. how many points to be added to the loyalty card. | | +| **object** | **String** | Type of object taken under consideration. | | +| **id** | **String** | Unique ID of the resource, i.e. pc_75U0dHlr7u75BJodrW1AE3t6, prod_0bae32322150fd0546, or sku_0b7d7dfb090be5c619. | | + diff --git a/docs/EarningRuleProportionalOrderItemsQuantity.md b/docs/EarningRuleProportionalOrderItemsQuantity.md new file mode 100644 index 00000000..ccd7bca9 --- /dev/null +++ b/docs/EarningRuleProportionalOrderItemsQuantity.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalOrderItemsQuantity + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | `ORDER_ITEMS_QUANTITY`: Quantity of items defined in order_items.quantity.object & .id (X points for every Y items excluding free items) | [default to 'ORDER_ITEMS_QUANTITY'] | +| **order_items** | [**EarningRuleProportionalOrderItemsQuantityOrderItems**](EarningRuleProportionalOrderItemsQuantityOrderItems.md) | | | + diff --git a/docs/EarningRuleProportionalOrderItemsQuantityOrderItems.md b/docs/EarningRuleProportionalOrderItemsQuantityOrderItems.md new file mode 100644 index 00000000..9d60b703 --- /dev/null +++ b/docs/EarningRuleProportionalOrderItemsQuantityOrderItems.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalOrderItemsQuantityOrderItems + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **quantity** | [**EarningRuleProportionalOrderItemsAmountOrderItemsAmount**](EarningRuleProportionalOrderItemsAmountOrderItemsAmount.md) | | | + diff --git a/docs/EarningRuleProportionalOrderItemsSubtotalAmount.md b/docs/EarningRuleProportionalOrderItemsSubtotalAmount.md new file mode 100644 index 00000000..2aeee3cf --- /dev/null +++ b/docs/EarningRuleProportionalOrderItemsSubtotalAmount.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmount + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | ORDER_ITEMS_SUBTOTAL_AMOUNT; Amount spent on items defined in the order_items.subtotal_amount.object & .id (X points for every Y spent on items including discounts) | [default to 'ORDER_ITEMS_SUBTOTAL_AMOUNT'] | +| **order_items** | [**EarningRuleProportionalOrderItemsSubtotalAmountOrderItems**](EarningRuleProportionalOrderItemsSubtotalAmountOrderItems.md) | | | + diff --git a/docs/EarningRuleProportionalOrderItemsSubtotalAmountOrderItems.md b/docs/EarningRuleProportionalOrderItemsSubtotalAmountOrderItems.md new file mode 100644 index 00000000..4292dc10 --- /dev/null +++ b/docs/EarningRuleProportionalOrderItemsSubtotalAmountOrderItems.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmountOrderItems + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **subtotal_amount** | [**EarningRuleProportionalOrderItemsAmountOrderItemsAmount**](EarningRuleProportionalOrderItemsAmountOrderItemsAmount.md) | | | + diff --git a/docs/EarningRuleProportionalOrderMetadata.md b/docs/EarningRuleProportionalOrderMetadata.md new file mode 100644 index 00000000..10959abd --- /dev/null +++ b/docs/EarningRuleProportionalOrderMetadata.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalOrderMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | `ORDER_METADATA`: Order Metadata (X points for every Y in metadata attribute, defined in the property key under the order.metadata object) | [default to 'ORDER_METADATA'] | +| **order** | [**EarningRuleProportionalOrderMetadataOrder**](EarningRuleProportionalOrderMetadataOrder.md) | | | + diff --git a/docs/EarningRuleProportionalOrderMetadataOrder.md b/docs/EarningRuleProportionalOrderMetadataOrder.md new file mode 100644 index 00000000..e6c3019d --- /dev/null +++ b/docs/EarningRuleProportionalOrderMetadataOrder.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalOrderMetadataOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **metadata** | [**EarningRuleProportionalOrderMetadataOrderMetadata**](EarningRuleProportionalOrderMetadataOrderMetadata.md) | | | + diff --git a/docs/EarningRuleProportionalOrderMetadataOrderMetadata.md b/docs/EarningRuleProportionalOrderMetadataOrderMetadata.md new file mode 100644 index 00000000..618e3762 --- /dev/null +++ b/docs/EarningRuleProportionalOrderMetadataOrderMetadata.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalOrderMetadataOrderMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **every** | **Integer** | For how many increments of the order metadata property to grant points for. | | +| **points** | **Integer** | Number of points to be awarded, i.e. how many points to be added to the loyalty card. | | +| **property** | **String** | Order metadata property. | | + diff --git a/docs/EarningRuleProportionalOrderTotalAmount.md b/docs/EarningRuleProportionalOrderTotalAmount.md new file mode 100644 index 00000000..b9f1952c --- /dev/null +++ b/docs/EarningRuleProportionalOrderTotalAmount.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EarningRuleProportionalOrderTotalAmount + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. | [default to 'PROPORTIONAL'] | +| **calculation_type** | **String** | `ORDER_TOTAL_AMOUNT`: Total order amount (X points for every Y spent including discount) | [default to 'ORDER_TOTAL_AMOUNT'] | +| **order** | [**EarningRuleProportionalOrderTotalAmountOrder**](EarningRuleProportionalOrderTotalAmountOrder.md) | | | + diff --git a/docs/EarningRuleProportionalOrderTotalAmountOrder.md b/docs/EarningRuleProportionalOrderTotalAmountOrder.md new file mode 100644 index 00000000..47fa9591 --- /dev/null +++ b/docs/EarningRuleProportionalOrderTotalAmountOrder.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EarningRuleProportionalOrderTotalAmountOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total_amount** | [**EarningRuleProportionalOrderAmountOrderAmount**](EarningRuleProportionalOrderAmountOrderAmount.md) | | | + diff --git a/docs/Error.md b/docs/Error.md new file mode 100644 index 00000000..5eb5ac24 --- /dev/null +++ b/docs/Error.md @@ -0,0 +1,14 @@ +# VoucherifySdk::Error + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **Integer** | Error's HTTP status code. | | +| **key** | **String** | Short string describing the kind of error which occurred. | | +| **message** | **String** | A human-readable message providing a short description about the error. | | +| **details** | **String** | A human-readable message providing more details about the error. | | +| **request_id** | **String** | This ID is useful when troubleshooting and/or finding the root cause of an error response by our support team. | | +| **resource_id** | **String** | Unique resource ID that can be used in another endpoint to get more details. | [optional] | +| **resource_type** | **String** | The resource type. | [optional] | + diff --git a/docs/EventCustomerActiveCampaignFailed.md b/docs/EventCustomerActiveCampaignFailed.md new file mode 100644 index 00000000..96579b38 --- /dev/null +++ b/docs/EventCustomerActiveCampaignFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerActiveCampaignFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerActiveCampaignRecovered.md b/docs/EventCustomerActiveCampaignRecovered.md new file mode 100644 index 00000000..18bbfc80 --- /dev/null +++ b/docs/EventCustomerActiveCampaignRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerActiveCampaignRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerActiveCampaignSent.md b/docs/EventCustomerActiveCampaignSent.md new file mode 100644 index 00000000..1eafe7dd --- /dev/null +++ b/docs/EventCustomerActiveCampaignSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerActiveCampaignSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerBatchFailed.md b/docs/EventCustomerBatchFailed.md new file mode 100644 index 00000000..ae2d0623 --- /dev/null +++ b/docs/EventCustomerBatchFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerBatchFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerBatchRecovered.md b/docs/EventCustomerBatchRecovered.md new file mode 100644 index 00000000..97db31e7 --- /dev/null +++ b/docs/EventCustomerBatchRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerBatchRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerBatchSent.md b/docs/EventCustomerBatchSent.md new file mode 100644 index 00000000..1dc588ed --- /dev/null +++ b/docs/EventCustomerBatchSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerBatchSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerBrazeFailed.md b/docs/EventCustomerBrazeFailed.md new file mode 100644 index 00000000..69d3c027 --- /dev/null +++ b/docs/EventCustomerBrazeFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerBrazeFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerBrazeRecovered.md b/docs/EventCustomerBrazeRecovered.md new file mode 100644 index 00000000..266d16ca --- /dev/null +++ b/docs/EventCustomerBrazeRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerBrazeRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerBrazeSent.md b/docs/EventCustomerBrazeSent.md new file mode 100644 index 00000000..d8e80207 --- /dev/null +++ b/docs/EventCustomerBrazeSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerBrazeSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerConfirmed.md b/docs/EventCustomerConfirmed.md new file mode 100644 index 00000000..51822790 --- /dev/null +++ b/docs/EventCustomerConfirmed.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerConfirmed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | [optional] | +| **unconfirmed_customer** | [**EventCustomerConfirmedUnconfirmedCustomer**](EventCustomerConfirmedUnconfirmedCustomer.md) | | [optional] | + diff --git a/docs/EventCustomerConfirmedUnconfirmedCustomer.md b/docs/EventCustomerConfirmedUnconfirmedCustomer.md new file mode 100644 index 00000000..110223cf --- /dev/null +++ b/docs/EventCustomerConfirmedUnconfirmedCustomer.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EventCustomerConfirmedUnconfirmedCustomer + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | [optional] | + diff --git a/docs/EventCustomerConsents.md b/docs/EventCustomerConsents.md new file mode 100644 index 00000000..df874dd7 --- /dev/null +++ b/docs/EventCustomerConsents.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerConsents + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **consents** | [**Array<SimpleConsent>**](SimpleConsent.md) | | [optional] | + diff --git a/docs/EventCustomerConsentsGiven.md b/docs/EventCustomerConsentsGiven.md new file mode 100644 index 00000000..96a0d006 --- /dev/null +++ b/docs/EventCustomerConsentsGiven.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerConsentsGiven + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **consents** | [**Array<SimpleConsent>**](SimpleConsent.md) | | [optional] | + diff --git a/docs/EventCustomerConsentsRevoked.md b/docs/EventCustomerConsentsRevoked.md new file mode 100644 index 00000000..7c1833d5 --- /dev/null +++ b/docs/EventCustomerConsentsRevoked.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerConsentsRevoked + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **consents** | [**Array<SimpleConsent>**](SimpleConsent.md) | | [optional] | + diff --git a/docs/EventCustomerCreated.md b/docs/EventCustomerCreated.md new file mode 100644 index 00000000..d9fb3416 --- /dev/null +++ b/docs/EventCustomerCreated.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EventCustomerCreated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | [optional] | + diff --git a/docs/EventCustomerCustomEvent.md b/docs/EventCustomerCustomEvent.md new file mode 100644 index 00000000..1769fd85 --- /dev/null +++ b/docs/EventCustomerCustomEvent.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EventCustomerCustomEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | + diff --git a/docs/EventCustomerDeleted.md b/docs/EventCustomerDeleted.md new file mode 100644 index 00000000..b2829f87 --- /dev/null +++ b/docs/EventCustomerDeleted.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EventCustomerDeleted + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | [optional] | + diff --git a/docs/EventCustomerEmailFailed.md b/docs/EventCustomerEmailFailed.md new file mode 100644 index 00000000..f3ca13f3 --- /dev/null +++ b/docs/EventCustomerEmailFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerEmailFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerEmailRecovered.md b/docs/EventCustomerEmailRecovered.md new file mode 100644 index 00000000..d3bace14 --- /dev/null +++ b/docs/EventCustomerEmailRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerEmailRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerEmailSent.md b/docs/EventCustomerEmailSent.md new file mode 100644 index 00000000..3f82c9b0 --- /dev/null +++ b/docs/EventCustomerEmailSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerEmailSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerFailed.md b/docs/EventCustomerFailed.md new file mode 100644 index 00000000..2d2f4abd --- /dev/null +++ b/docs/EventCustomerFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerGiftVoucherBalanceAdded.md b/docs/EventCustomerGiftVoucherBalanceAdded.md new file mode 100644 index 00000000..e3b1e006 --- /dev/null +++ b/docs/EventCustomerGiftVoucherBalanceAdded.md @@ -0,0 +1,12 @@ +# VoucherifySdk::EventCustomerGiftVoucherBalanceAdded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **balance** | **Integer** | | [optional] | +| **transaction** | [**VoucherTransaction**](VoucherTransaction.md) | | [optional] | + diff --git a/docs/EventCustomerIntercomFailed.md b/docs/EventCustomerIntercomFailed.md new file mode 100644 index 00000000..7aa08d30 --- /dev/null +++ b/docs/EventCustomerIntercomFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerIntercomFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerIntercomRecovered.md b/docs/EventCustomerIntercomRecovered.md new file mode 100644 index 00000000..b0d67989 --- /dev/null +++ b/docs/EventCustomerIntercomRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerIntercomRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerIntercomSent.md b/docs/EventCustomerIntercomSent.md new file mode 100644 index 00000000..97960b8d --- /dev/null +++ b/docs/EventCustomerIntercomSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerIntercomSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerKlaviyoFailed.md b/docs/EventCustomerKlaviyoFailed.md new file mode 100644 index 00000000..e98de7ad --- /dev/null +++ b/docs/EventCustomerKlaviyoFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerKlaviyoFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerKlaviyoRecovered.md b/docs/EventCustomerKlaviyoRecovered.md new file mode 100644 index 00000000..d6dbd02f --- /dev/null +++ b/docs/EventCustomerKlaviyoRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerKlaviyoRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerKlaviyoSent.md b/docs/EventCustomerKlaviyoSent.md new file mode 100644 index 00000000..6d9342c2 --- /dev/null +++ b/docs/EventCustomerKlaviyoSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerKlaviyoSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerLoyaltyCardPointsAdded.md b/docs/EventCustomerLoyaltyCardPointsAdded.md new file mode 100644 index 00000000..7590039e --- /dev/null +++ b/docs/EventCustomerLoyaltyCardPointsAdded.md @@ -0,0 +1,12 @@ +# VoucherifySdk::EventCustomerLoyaltyCardPointsAdded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **balance** | **Integer** | | [optional] | +| **transaction** | [**VoucherTransaction**](VoucherTransaction.md) | | [optional] | + diff --git a/docs/EventCustomerLoyaltyCardPointsTransferred.md b/docs/EventCustomerLoyaltyCardPointsTransferred.md new file mode 100644 index 00000000..299993ae --- /dev/null +++ b/docs/EventCustomerLoyaltyCardPointsTransferred.md @@ -0,0 +1,14 @@ +# VoucherifySdk::EventCustomerLoyaltyCardPointsTransferred + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **source_voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **destination_voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **balance** | **Integer** | | [optional] | +| **transaction** | [**VoucherTransaction**](VoucherTransaction.md) | | [optional] | + diff --git a/docs/EventCustomerLoyaltyTierBase.md b/docs/EventCustomerLoyaltyTierBase.md new file mode 100644 index 00000000..0976cdc7 --- /dev/null +++ b/docs/EventCustomerLoyaltyTierBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerLoyaltyTierBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | + diff --git a/docs/EventCustomerLoyaltyTierDowngraded.md b/docs/EventCustomerLoyaltyTierDowngraded.md new file mode 100644 index 00000000..3fa6920c --- /dev/null +++ b/docs/EventCustomerLoyaltyTierDowngraded.md @@ -0,0 +1,12 @@ +# VoucherifySdk::EventCustomerLoyaltyTierDowngraded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty_tier_from** | [**LoyaltyTier**](LoyaltyTier.md) | | | +| **loyalty_tier_to** | [**LoyaltyTier**](LoyaltyTier.md) | | | +| **created_at** | **Time** | | | + diff --git a/docs/EventCustomerLoyaltyTierExpirationChanged.md b/docs/EventCustomerLoyaltyTierExpirationChanged.md new file mode 100644 index 00000000..ced9c97d --- /dev/null +++ b/docs/EventCustomerLoyaltyTierExpirationChanged.md @@ -0,0 +1,12 @@ +# VoucherifySdk::EventCustomerLoyaltyTierExpirationChanged + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty_tier** | [**LoyaltyTier**](LoyaltyTier.md) | | | +| **created_at** | **Time** | | | +| **expiration_date** | **Time** | | | + diff --git a/docs/EventCustomerLoyaltyTierJoined.md b/docs/EventCustomerLoyaltyTierJoined.md new file mode 100644 index 00000000..f561331f --- /dev/null +++ b/docs/EventCustomerLoyaltyTierJoined.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerLoyaltyTierJoined + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty_tier** | [**LoyaltyTier**](LoyaltyTier.md) | | | +| **created_at** | **Time** | | | + diff --git a/docs/EventCustomerLoyaltyTierLeft.md b/docs/EventCustomerLoyaltyTierLeft.md new file mode 100644 index 00000000..7fa7e84e --- /dev/null +++ b/docs/EventCustomerLoyaltyTierLeft.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerLoyaltyTierLeft + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty_tier** | [**LoyaltyTier**](LoyaltyTier.md) | | | +| **created_at** | **Time** | | | + diff --git a/docs/EventCustomerLoyaltyTierProlonged.md b/docs/EventCustomerLoyaltyTierProlonged.md new file mode 100644 index 00000000..ac56ba91 --- /dev/null +++ b/docs/EventCustomerLoyaltyTierProlonged.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerLoyaltyTierProlonged + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty_tier** | [**LoyaltyTier**](LoyaltyTier.md) | | | +| **created_at** | **Time** | | | + diff --git a/docs/EventCustomerLoyaltyTierUpgraded.md b/docs/EventCustomerLoyaltyTierUpgraded.md new file mode 100644 index 00000000..33daa77a --- /dev/null +++ b/docs/EventCustomerLoyaltyTierUpgraded.md @@ -0,0 +1,12 @@ +# VoucherifySdk::EventCustomerLoyaltyTierUpgraded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty_tier_from** | [**LoyaltyTier**](LoyaltyTier.md) | | [optional] | +| **loyalty_tier_to** | [**LoyaltyTier**](LoyaltyTier.md) | | | +| **created_at** | **Time** | | | + diff --git a/docs/EventCustomerLoyaltyUpdated.md b/docs/EventCustomerLoyaltyUpdated.md new file mode 100644 index 00000000..ffdae02b --- /dev/null +++ b/docs/EventCustomerLoyaltyUpdated.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerLoyaltyUpdated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty** | **Object** | | [optional] | +| **created_at** | **Time** | | | + diff --git a/docs/EventCustomerMailchimpFailed.md b/docs/EventCustomerMailchimpFailed.md new file mode 100644 index 00000000..3e6d451a --- /dev/null +++ b/docs/EventCustomerMailchimpFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerMailchimpFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerMailchimpRecovered.md b/docs/EventCustomerMailchimpRecovered.md new file mode 100644 index 00000000..71824d93 --- /dev/null +++ b/docs/EventCustomerMailchimpRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerMailchimpRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerMailchimpSent.md b/docs/EventCustomerMailchimpSent.md new file mode 100644 index 00000000..916135c9 --- /dev/null +++ b/docs/EventCustomerMailchimpSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerMailchimpSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerOrder.md b/docs/EventCustomerOrder.md new file mode 100644 index 00000000..339b03ad --- /dev/null +++ b/docs/EventCustomerOrder.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerOrderCanceled.md b/docs/EventCustomerOrderCanceled.md new file mode 100644 index 00000000..f3cc037c --- /dev/null +++ b/docs/EventCustomerOrderCanceled.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerOrderCanceled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerOrderCreated.md b/docs/EventCustomerOrderCreated.md new file mode 100644 index 00000000..27896e17 --- /dev/null +++ b/docs/EventCustomerOrderCreated.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerOrderCreated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerOrderFulfilled.md b/docs/EventCustomerOrderFulfilled.md new file mode 100644 index 00000000..f35d7c6d --- /dev/null +++ b/docs/EventCustomerOrderFulfilled.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerOrderFulfilled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerOrderPaid.md b/docs/EventCustomerOrderPaid.md new file mode 100644 index 00000000..bccba28c --- /dev/null +++ b/docs/EventCustomerOrderPaid.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerOrderPaid + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerOrderProcessing.md b/docs/EventCustomerOrderProcessing.md new file mode 100644 index 00000000..b5cdbc80 --- /dev/null +++ b/docs/EventCustomerOrderProcessing.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerOrderProcessing + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerOrderUpdated.md b/docs/EventCustomerOrderUpdated.md new file mode 100644 index 00000000..0d97d514 --- /dev/null +++ b/docs/EventCustomerOrderUpdated.md @@ -0,0 +1,11 @@ +# VoucherifySdk::EventCustomerOrderUpdated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerPublicationFailed.md b/docs/EventCustomerPublicationFailed.md new file mode 100644 index 00000000..097a534f --- /dev/null +++ b/docs/EventCustomerPublicationFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerPublicationFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **publication** | **Object** | | [optional] | + diff --git a/docs/EventCustomerPublicationSucceeded.md b/docs/EventCustomerPublicationSucceeded.md new file mode 100644 index 00000000..3be0c404 --- /dev/null +++ b/docs/EventCustomerPublicationSucceeded.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerPublicationSucceeded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **publication** | **Object** | | [optional] | + diff --git a/docs/EventCustomerRecovered.md b/docs/EventCustomerRecovered.md new file mode 100644 index 00000000..f19486fd --- /dev/null +++ b/docs/EventCustomerRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerRedemption.md b/docs/EventCustomerRedemption.md new file mode 100644 index 00000000..113289d3 --- /dev/null +++ b/docs/EventCustomerRedemption.md @@ -0,0 +1,14 @@ +# VoucherifySdk::EventCustomerRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**SimpleOrder**](SimpleOrder.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **promotion_tier** | [**SimplePromotionTier**](SimplePromotionTier.md) | | [optional] | +| **redemption** | [**SimpleRedemption**](SimpleRedemption.md) | | [optional] | + diff --git a/docs/EventCustomerRedemptionFailed.md b/docs/EventCustomerRedemptionFailed.md new file mode 100644 index 00000000..02905ebd --- /dev/null +++ b/docs/EventCustomerRedemptionFailed.md @@ -0,0 +1,14 @@ +# VoucherifySdk::EventCustomerRedemptionFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**SimpleOrder**](SimpleOrder.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **promotion_tier** | [**SimplePromotionTier**](SimplePromotionTier.md) | | [optional] | +| **redemption** | [**SimpleRedemption**](SimpleRedemption.md) | | [optional] | + diff --git a/docs/EventCustomerRedemptionRollbackFailed.md b/docs/EventCustomerRedemptionRollbackFailed.md new file mode 100644 index 00000000..086b24ac --- /dev/null +++ b/docs/EventCustomerRedemptionRollbackFailed.md @@ -0,0 +1,15 @@ +# VoucherifySdk::EventCustomerRedemptionRollbackFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**SimpleOrder**](SimpleOrder.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **promotion_tier** | [**SimplePromotionTier**](SimplePromotionTier.md) | | [optional] | +| **redemption** | [**SimpleRedemption**](SimpleRedemption.md) | | [optional] | +| **redemption_rollback** | [**SimpleRedemption**](SimpleRedemption.md) | | [optional] | + diff --git a/docs/EventCustomerRedemptionRollbackSucceeded.md b/docs/EventCustomerRedemptionRollbackSucceeded.md new file mode 100644 index 00000000..4b846f4a --- /dev/null +++ b/docs/EventCustomerRedemptionRollbackSucceeded.md @@ -0,0 +1,15 @@ +# VoucherifySdk::EventCustomerRedemptionRollbackSucceeded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**SimpleOrder**](SimpleOrder.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **promotion_tier** | [**SimplePromotionTier**](SimplePromotionTier.md) | | [optional] | +| **redemption** | [**SimpleRedemption**](SimpleRedemption.md) | | [optional] | +| **redemption_rollback** | [**SimpleRedemption**](SimpleRedemption.md) | | [optional] | + diff --git a/docs/EventCustomerRedemptionSucceeded.md b/docs/EventCustomerRedemptionSucceeded.md new file mode 100644 index 00000000..8604d304 --- /dev/null +++ b/docs/EventCustomerRedemptionSucceeded.md @@ -0,0 +1,14 @@ +# VoucherifySdk::EventCustomerRedemptionSucceeded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **order** | [**SimpleOrder**](SimpleOrder.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **promotion_tier** | [**SimplePromotionTier**](SimplePromotionTier.md) | | [optional] | +| **redemption** | [**SimpleRedemption**](SimpleRedemption.md) | | [optional] | + diff --git a/docs/EventCustomerReferred.md b/docs/EventCustomerReferred.md new file mode 100644 index 00000000..e142284e --- /dev/null +++ b/docs/EventCustomerReferred.md @@ -0,0 +1,13 @@ +# VoucherifySdk::EventCustomerReferred + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **referrer** | [**SimpleCustomer**](SimpleCustomer.md) | | | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | | +| **custom_event** | [**CustomEvent**](CustomEvent.md) | | | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | + diff --git a/docs/EventCustomerRewardRedemptions.md b/docs/EventCustomerRewardRedemptions.md new file mode 100644 index 00000000..efb89dfb --- /dev/null +++ b/docs/EventCustomerRewardRedemptions.md @@ -0,0 +1,16 @@ +# VoucherifySdk::EventCustomerRewardRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **reward_redemption** | **Object** | | [optional] | +| **reward** | [**SimpleRedemptionRewardResult**](SimpleRedemptionRewardResult.md) | | [optional] | +| **reward_assignment** | [**RewardAssignment**](RewardAssignment.md) | | [optional] | +| **source** | **String** | | [optional] | +| **balance** | **Integer** | | [optional] | + diff --git a/docs/EventCustomerRewardRedemptionsCompleted.md b/docs/EventCustomerRewardRedemptionsCompleted.md new file mode 100644 index 00000000..f9062cea --- /dev/null +++ b/docs/EventCustomerRewardRedemptionsCompleted.md @@ -0,0 +1,16 @@ +# VoucherifySdk::EventCustomerRewardRedemptionsCompleted + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **reward_redemption** | **Object** | | [optional] | +| **reward** | [**SimpleRedemptionRewardResult**](SimpleRedemptionRewardResult.md) | | [optional] | +| **reward_assignment** | [**RewardAssignment**](RewardAssignment.md) | | [optional] | +| **source** | **String** | | [optional] | +| **balance** | **Integer** | | [optional] | + diff --git a/docs/EventCustomerRewardRedemptionsCreated.md b/docs/EventCustomerRewardRedemptionsCreated.md new file mode 100644 index 00000000..08f6fb6e --- /dev/null +++ b/docs/EventCustomerRewardRedemptionsCreated.md @@ -0,0 +1,16 @@ +# VoucherifySdk::EventCustomerRewardRedemptionsCreated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **reward_redemption** | **Object** | | [optional] | +| **reward** | [**SimpleRedemptionRewardResult**](SimpleRedemptionRewardResult.md) | | [optional] | +| **reward_assignment** | [**RewardAssignment**](RewardAssignment.md) | | [optional] | +| **source** | **String** | | [optional] | +| **balance** | **Integer** | | [optional] | + diff --git a/docs/EventCustomerRewardRedemptionsPending.md b/docs/EventCustomerRewardRedemptionsPending.md new file mode 100644 index 00000000..e24df81e --- /dev/null +++ b/docs/EventCustomerRewardRedemptionsPending.md @@ -0,0 +1,16 @@ +# VoucherifySdk::EventCustomerRewardRedemptionsPending + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **reward_redemption** | **Object** | | [optional] | +| **reward** | [**SimpleRedemptionRewardResult**](SimpleRedemptionRewardResult.md) | | [optional] | +| **reward_assignment** | [**RewardAssignment**](RewardAssignment.md) | | [optional] | +| **source** | **String** | | [optional] | +| **balance** | **Integer** | | [optional] | + diff --git a/docs/EventCustomerRewardRedemptionsRolledBack.md b/docs/EventCustomerRewardRedemptionsRolledBack.md new file mode 100644 index 00000000..60b393f8 --- /dev/null +++ b/docs/EventCustomerRewardRedemptionsRolledBack.md @@ -0,0 +1,16 @@ +# VoucherifySdk::EventCustomerRewardRedemptionsRolledBack + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **reward_redemption** | **Object** | | [optional] | +| **reward** | [**SimpleRedemptionRewardResult**](SimpleRedemptionRewardResult.md) | | [optional] | +| **reward_assignment** | [**RewardAssignment**](RewardAssignment.md) | | [optional] | +| **source** | **String** | | [optional] | +| **balance** | **Integer** | | [optional] | + diff --git a/docs/EventCustomerRewarded.md b/docs/EventCustomerRewarded.md new file mode 100644 index 00000000..693ccae0 --- /dev/null +++ b/docs/EventCustomerRewarded.md @@ -0,0 +1,17 @@ +# VoucherifySdk::EventCustomerRewarded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **redemption** | [**RedemptionInternal**](RedemptionInternal.md) | | [optional] | +| **reward** | [**SimpleRedemptionRewardResult**](SimpleRedemptionRewardResult.md) | | [optional] | +| **referral_tier** | [**SimpleReferralTier**](SimpleReferralTier.md) | | [optional] | +| **balance** | **Integer** | | [optional] | +| **custom_event** | [**CustomEvent**](CustomEvent.md) | | [optional] | +| **customer_event** | **Object** | | [optional] | + diff --git a/docs/EventCustomerRewardedLoyaltyPoints.md b/docs/EventCustomerRewardedLoyaltyPoints.md new file mode 100644 index 00000000..7dc4bb63 --- /dev/null +++ b/docs/EventCustomerRewardedLoyaltyPoints.md @@ -0,0 +1,16 @@ +# VoucherifySdk::EventCustomerRewardedLoyaltyPoints + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **loyalty_tier** | [**LoyaltyTier**](LoyaltyTier.md) | | [optional] | +| **earning_rule** | [**EarningRule**](EarningRule.md) | | [optional] | +| **balance** | **Integer** | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **event** | **Object** | | [optional] | + diff --git a/docs/EventCustomerSegmentEntered.md b/docs/EventCustomerSegmentEntered.md new file mode 100644 index 00000000..a91663ba --- /dev/null +++ b/docs/EventCustomerSegmentEntered.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerSegmentEntered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **segment** | [**SimpleSegment**](SimpleSegment.md) | | | + diff --git a/docs/EventCustomerSegmentLeft.md b/docs/EventCustomerSegmentLeft.md new file mode 100644 index 00000000..18fb1fd7 --- /dev/null +++ b/docs/EventCustomerSegmentLeft.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerSegmentLeft + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **segment** | [**SimpleSegment**](SimpleSegment.md) | | | + diff --git a/docs/EventCustomerSent.md b/docs/EventCustomerSent.md new file mode 100644 index 00000000..108b972b --- /dev/null +++ b/docs/EventCustomerSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerShopifyFailed.md b/docs/EventCustomerShopifyFailed.md new file mode 100644 index 00000000..d2b9d541 --- /dev/null +++ b/docs/EventCustomerShopifyFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerShopifyFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerShopifyRecovered.md b/docs/EventCustomerShopifyRecovered.md new file mode 100644 index 00000000..77da1fab --- /dev/null +++ b/docs/EventCustomerShopifyRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerShopifyRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerShopifySent.md b/docs/EventCustomerShopifySent.md new file mode 100644 index 00000000..323b29bb --- /dev/null +++ b/docs/EventCustomerShopifySent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerShopifySent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerSmsFailed.md b/docs/EventCustomerSmsFailed.md new file mode 100644 index 00000000..0687e81b --- /dev/null +++ b/docs/EventCustomerSmsFailed.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerSmsFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **failed_at** | **Time** | Timestamp representing the date and time when the distribution failed in ISO 8601 format. | | + diff --git a/docs/EventCustomerSmsRecovered.md b/docs/EventCustomerSmsRecovered.md new file mode 100644 index 00000000..6208d484 --- /dev/null +++ b/docs/EventCustomerSmsRecovered.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerSmsRecovered + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **recovered_at** | **Time** | Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. | | + diff --git a/docs/EventCustomerSmsSent.md b/docs/EventCustomerSmsSent.md new file mode 100644 index 00000000..6225f469 --- /dev/null +++ b/docs/EventCustomerSmsSent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerSmsSent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **distribution** | **Object** | | [optional] | +| **sent_at** | **Time** | Timestamp representing the date and time when the distribution was sent in ISO 8601 format. | | + diff --git a/docs/EventCustomerUpdated.md b/docs/EventCustomerUpdated.md new file mode 100644 index 00000000..99ddec9e --- /dev/null +++ b/docs/EventCustomerUpdated.md @@ -0,0 +1,8 @@ +# VoucherifySdk::EventCustomerUpdated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | [optional] | + diff --git a/docs/EventCustomerValidationFailed.md b/docs/EventCustomerValidationFailed.md new file mode 100644 index 00000000..fb267b83 --- /dev/null +++ b/docs/EventCustomerValidationFailed.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerValidationFailed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **validation** | [**ValidationEntity**](ValidationEntity.md) | | [optional] | + diff --git a/docs/EventCustomerValidationSucceeded.md b/docs/EventCustomerValidationSucceeded.md new file mode 100644 index 00000000..48f3ff5e --- /dev/null +++ b/docs/EventCustomerValidationSucceeded.md @@ -0,0 +1,9 @@ +# VoucherifySdk::EventCustomerValidationSucceeded + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **validation** | [**ValidationEntity**](ValidationEntity.md) | | [optional] | + diff --git a/docs/EventCustomerVoucherDeleted.md b/docs/EventCustomerVoucherDeleted.md new file mode 100644 index 00000000..e8229dd7 --- /dev/null +++ b/docs/EventCustomerVoucherDeleted.md @@ -0,0 +1,10 @@ +# VoucherifySdk::EventCustomerVoucherDeleted + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | + diff --git a/docs/EventCustomerVouchersLoyaltyPointsExpired.md b/docs/EventCustomerVouchersLoyaltyPointsExpired.md new file mode 100644 index 00000000..95e9da71 --- /dev/null +++ b/docs/EventCustomerVouchersLoyaltyPointsExpired.md @@ -0,0 +1,13 @@ +# VoucherifySdk::EventCustomerVouchersLoyaltyPointsExpired + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **campaign** | [**SimpleCampaign**](SimpleCampaign.md) | | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **points** | **Integer** | | [optional] | +| **buckets** | [**Array<VoucherTransaction>**](VoucherTransaction.md) | | [optional] | +| **transaction** | [**VoucherTransaction**](VoucherTransaction.md) | | [optional] | + diff --git a/docs/EventsApi.md b/docs/EventsApi.md new file mode 100644 index 00000000..eb58b79a --- /dev/null +++ b/docs/EventsApi.md @@ -0,0 +1,68 @@ +# VoucherifySdk::EventsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**track_custom_event**](EventsApi.md#track_custom_event) | **POST** /v1/events | Track Custom Event | + + +## track_custom_event + +> track_custom_event(opts) + +Track Custom Event + +To track a custom event, you create an event object. The event object must be linked to the customer who performs the action. If a customer doesnt exist in Voucherify, the customer will be created. + +### 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::EventsApi.new +opts = { + events_create_request_body: VoucherifySdk::EventsCreateRequestBody.new({event: 'event_example', customer: VoucherifySdk::Customer.new}) # EventsCreateRequestBody | Specify the details of the custom event. +} + +begin + # Track Custom Event + result = api_instance.track_custom_event(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling EventsApi->track_custom_event: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **events_create_request_body** | [**EventsCreateRequestBody**](EventsCreateRequestBody.md) | Specify the details of the custom event. | [optional] | + +### Return type + +[**EventsCreateResponseBody**](EventsCreateResponseBody.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 + diff --git a/docs/EventsCreateRequestBody.md b/docs/EventsCreateRequestBody.md new file mode 100644 index 00000000..47e67d07 --- /dev/null +++ b/docs/EventsCreateRequestBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::EventsCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event** | **String** | Event name. This is the same name that you used to define a custom event in the **Dashboard** > **Project Settings** > **Event Schema**. | | +| **customer** | [**Customer**](Customer.md) | | | +| **referral** | [**ClientEventsCreateRequestBodyReferral**](ClientEventsCreateRequestBodyReferral.md) | | [optional] | +| **loyalty** | [**ClientEventsCreateRequestBodyLoyalty**](ClientEventsCreateRequestBodyLoyalty.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the event. A set of key/value pairs that you can attach to an event object. It can be useful for storing additional information about the event in a structured format. Event metadata schema is defined in the **Dashboard** > **Project Settings** > **Event Schema** > **Edit particular event** > **Metadata property definition**. | [optional] | + diff --git a/docs/EventsCreateResponseBody.md b/docs/EventsCreateResponseBody.md new file mode 100644 index 00000000..da1b1f52 --- /dev/null +++ b/docs/EventsCreateResponseBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::EventsCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The object represented is an `event`. | [default to 'event'] | +| **type** | **String** | The event name. | | +| **customer** | [**SimpleCustomerRequiredObjectType**](SimpleCustomerRequiredObjectType.md) | | | +| **referral** | **Object** | A `null` referral object. | | +| **loyalty** | **Object** | A `null` loyalty object. | | + diff --git a/docs/Export.md b/docs/Export.md new file mode 100644 index 00000000..a98fa7a2 --- /dev/null +++ b/docs/Export.md @@ -0,0 +1,59 @@ +# VoucherifySdk::Export + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::Export.openapi_one_of +# => +# [ +# :'ExportCustomer', +# :'ExportOrder', +# :'ExportPointsExpiration', +# :'ExportPublication', +# :'ExportRedemption', +# :'ExportVoucher', +# :'ExportVoucherTransactions' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::Export.build(data) +# => # + +VoucherifySdk::Export.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ExportCustomer` +- `ExportOrder` +- `ExportPointsExpiration` +- `ExportPublication` +- `ExportRedemption` +- `ExportVoucher` +- `ExportVoucherTransactions` +- `nil` (if no type matches) + diff --git a/docs/ExportBase.md b/docs/ExportBase.md new file mode 100644 index 00000000..da84789d --- /dev/null +++ b/docs/ExportBase.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ExportBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | + diff --git a/docs/ExportBaseResult.md b/docs/ExportBaseResult.md new file mode 100644 index 00000000..b4f49b0b --- /dev/null +++ b/docs/ExportBaseResult.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ExportBaseResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **url** | **String** | URL of the CSV file location. It contains the token used for authorization in the Download export method. | | + diff --git a/docs/ExportCustomer.md b/docs/ExportCustomer.md new file mode 100644 index 00000000..480ba408 --- /dev/null +++ b/docs/ExportCustomer.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportCustomer + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'customer'] | +| **parameters** | [**ExportCustomerBaseParameters**](ExportCustomerBaseParameters.md) | | [optional] | + diff --git a/docs/ExportCustomerBase.md b/docs/ExportCustomerBase.md new file mode 100644 index 00000000..97da2902 --- /dev/null +++ b/docs/ExportCustomerBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ExportCustomerBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exported_object** | **String** | The type of object to be exported. | [default to 'customer'] | +| **parameters** | [**ExportCustomerBaseParameters**](ExportCustomerBaseParameters.md) | | [optional] | + diff --git a/docs/ExportCustomerBaseParameters.md b/docs/ExportCustomerBaseParameters.md new file mode 100644 index 00000000..47600401 --- /dev/null +++ b/docs/ExportCustomerBaseParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ExportCustomerBaseParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | [**ExportCustomerOrder**](ExportCustomerOrder.md) | | [optional] | +| **fields** | [**Array<ExportCustomerFields>**](ExportCustomerFields.md) | Array of strings containing the data in the export. These fields define the headers in the CSV file. | [optional] | +| **filters** | **Object** | Allowed additional properties must start with \"metadata.\" or \"address.\" or \"summary.\" or \"loyalty.\" or \"loyalty_tier.\" or \"loyalty_points.\" or \"system_metadata.\" | [optional] | + diff --git a/docs/ExportCustomerFields.md b/docs/ExportCustomerFields.md new file mode 100644 index 00000000..f8c74a89 --- /dev/null +++ b/docs/ExportCustomerFields.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportCustomerFields + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportCustomerFilters.md b/docs/ExportCustomerFilters.md new file mode 100644 index 00000000..34fc2f0c --- /dev/null +++ b/docs/ExportCustomerFilters.md @@ -0,0 +1,38 @@ +# VoucherifySdk::ExportCustomerFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **name** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **description** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **email** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **source_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **created_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **address_city** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **address_state** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **address_line_1** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **address_line_2** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **address_country** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **address_postal_code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemptions_total_redeemed** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemptions_total_failed** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemptions_total_succeeded** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemptions_total_rolled_back** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemptions_total_rollback_failed** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemptions_total_rollback_succeeded** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **orders_total_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **orders_total_count** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **orders_average_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **orders_last_order_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **orders_last_order_date** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **loyalty_points** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **loyalty_referred_customers** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **updated_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **phone** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **birthday** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **metadata** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **birthdate** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ExportCustomerOrder.md b/docs/ExportCustomerOrder.md new file mode 100644 index 00000000..1e22342b --- /dev/null +++ b/docs/ExportCustomerOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportCustomerOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportCustomerScheduled.md b/docs/ExportCustomerScheduled.md new file mode 100644 index 00000000..24e42285 --- /dev/null +++ b/docs/ExportCustomerScheduled.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportCustomerScheduled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'customer'] | +| **parameters** | [**ExportCustomerBaseParameters**](ExportCustomerBaseParameters.md) | | [optional] | + diff --git a/docs/ExportOrder.md b/docs/ExportOrder.md new file mode 100644 index 00000000..07669b9e --- /dev/null +++ b/docs/ExportOrder.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'order'] | +| **parameters** | [**OrdersExportCreateRequestBodyParameters**](OrdersExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/ExportOrderBase.md b/docs/ExportOrderBase.md new file mode 100644 index 00000000..ccaa6d0f --- /dev/null +++ b/docs/ExportOrderBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ExportOrderBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exported_object** | **String** | The type of object to be exported. | [default to 'order'] | +| **parameters** | [**OrdersExportCreateRequestBodyParameters**](OrdersExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/ExportOrderFields.md b/docs/ExportOrderFields.md new file mode 100644 index 00000000..a5744e6c --- /dev/null +++ b/docs/ExportOrderFields.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportOrderFields + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportOrderFilters.md b/docs/ExportOrderFilters.md new file mode 100644 index 00000000..92802b60 --- /dev/null +++ b/docs/ExportOrderFilters.md @@ -0,0 +1,21 @@ +# VoucherifySdk::ExportOrderFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **source_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **created_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **updated_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **status** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **discount_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **items_discount_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **total_discount_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **total_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **referrer_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **metadata** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ExportOrderOrder.md b/docs/ExportOrderOrder.md new file mode 100644 index 00000000..c5d1302c --- /dev/null +++ b/docs/ExportOrderOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportOrderOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportOrderScheduled.md b/docs/ExportOrderScheduled.md new file mode 100644 index 00000000..7a40f77c --- /dev/null +++ b/docs/ExportOrderScheduled.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportOrderScheduled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'order'] | +| **parameters** | [**OrdersExportCreateRequestBodyParameters**](OrdersExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/ExportPointsExpiration.md b/docs/ExportPointsExpiration.md new file mode 100644 index 00000000..f17e7a5b --- /dev/null +++ b/docs/ExportPointsExpiration.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportPointsExpiration + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'points_expiration'] | +| **parameters** | [**ExportPointsExpirationBaseParameters**](ExportPointsExpirationBaseParameters.md) | | [optional] | + diff --git a/docs/ExportPointsExpirationBase.md b/docs/ExportPointsExpirationBase.md new file mode 100644 index 00000000..922e36d1 --- /dev/null +++ b/docs/ExportPointsExpirationBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ExportPointsExpirationBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exported_object** | **String** | The type of object to be exported. | [default to 'points_expiration'] | +| **parameters** | [**ExportPointsExpirationBaseParameters**](ExportPointsExpirationBaseParameters.md) | | [optional] | + diff --git a/docs/ExportPointsExpirationBaseParameters.md b/docs/ExportPointsExpirationBaseParameters.md new file mode 100644 index 00000000..f2ab84da --- /dev/null +++ b/docs/ExportPointsExpirationBaseParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ExportPointsExpirationBaseParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | [**ExportPointsExpirationOrder**](ExportPointsExpirationOrder.md) | | [optional] | +| **fields** | [**Array<ExportPointsExpirationFields>**](ExportPointsExpirationFields.md) | Array of strings containing the data in the export. These fields define the headers in the CSV file. | [optional] | +| **filters** | [**ExportPointsExpirationFilters**](ExportPointsExpirationFilters.md) | | [optional] | + diff --git a/docs/ExportPointsExpirationFields.md b/docs/ExportPointsExpirationFields.md new file mode 100644 index 00000000..57a6223b --- /dev/null +++ b/docs/ExportPointsExpirationFields.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportPointsExpirationFields + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportPointsExpirationFilters.md b/docs/ExportPointsExpirationFilters.md new file mode 100644 index 00000000..afd53926 --- /dev/null +++ b/docs/ExportPointsExpirationFilters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ExportPointsExpirationFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **campaign_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **voucher_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ExportPointsExpirationOrder.md b/docs/ExportPointsExpirationOrder.md new file mode 100644 index 00000000..ae57565a --- /dev/null +++ b/docs/ExportPointsExpirationOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportPointsExpirationOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportPointsExpirationScheduled.md b/docs/ExportPointsExpirationScheduled.md new file mode 100644 index 00000000..ac1b8049 --- /dev/null +++ b/docs/ExportPointsExpirationScheduled.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportPointsExpirationScheduled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'points_expiration'] | +| **parameters** | [**ExportPointsExpirationBaseParameters**](ExportPointsExpirationBaseParameters.md) | | [optional] | + diff --git a/docs/ExportPublication.md b/docs/ExportPublication.md new file mode 100644 index 00000000..509eb98d --- /dev/null +++ b/docs/ExportPublication.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportPublication + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'publication'] | +| **parameters** | [**ExportPublicationBaseParameters**](ExportPublicationBaseParameters.md) | | [optional] | + diff --git a/docs/ExportPublicationBase.md b/docs/ExportPublicationBase.md new file mode 100644 index 00000000..8182e2d2 --- /dev/null +++ b/docs/ExportPublicationBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ExportPublicationBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exported_object** | **String** | The type of object to be exported. | [default to 'publication'] | +| **parameters** | [**ExportPublicationBaseParameters**](ExportPublicationBaseParameters.md) | | [optional] | + diff --git a/docs/ExportPublicationBaseParameters.md b/docs/ExportPublicationBaseParameters.md new file mode 100644 index 00000000..d65bb4a9 --- /dev/null +++ b/docs/ExportPublicationBaseParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ExportPublicationBaseParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | [**ExportPublicationOrder**](ExportPublicationOrder.md) | | [optional] | +| **fields** | [**Array<ExportPublicationFields>**](ExportPublicationFields.md) | Array of strings containing the data in the export. These fields define the headers in the CSV file. | [optional] | +| **filters** | **Object** | Allowed additional properties must start with \"metadata.\" | [optional] | + diff --git a/docs/ExportPublicationFields.md b/docs/ExportPublicationFields.md new file mode 100644 index 00000000..e61ecfb6 --- /dev/null +++ b/docs/ExportPublicationFields.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportPublicationFields + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportPublicationFilters.md b/docs/ExportPublicationFilters.md new file mode 100644 index 00000000..e56c5756 --- /dev/null +++ b/docs/ExportPublicationFilters.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportPublicationFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **voucher_code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_source_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **date** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **channel** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **campaign** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **is_winner** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **metadata** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ExportPublicationOrder.md b/docs/ExportPublicationOrder.md new file mode 100644 index 00000000..c81444a6 --- /dev/null +++ b/docs/ExportPublicationOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportPublicationOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportPublicationScheduled.md b/docs/ExportPublicationScheduled.md new file mode 100644 index 00000000..5bdd8866 --- /dev/null +++ b/docs/ExportPublicationScheduled.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportPublicationScheduled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'publication'] | +| **parameters** | [**ExportPublicationBaseParameters**](ExportPublicationBaseParameters.md) | | [optional] | + diff --git a/docs/ExportRedemption.md b/docs/ExportRedemption.md new file mode 100644 index 00000000..43835076 --- /dev/null +++ b/docs/ExportRedemption.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'redemption'] | +| **parameters** | [**ExportRedemptionBaseParameters**](ExportRedemptionBaseParameters.md) | | [optional] | + diff --git a/docs/ExportRedemptionBase.md b/docs/ExportRedemptionBase.md new file mode 100644 index 00000000..f0b4d3a6 --- /dev/null +++ b/docs/ExportRedemptionBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ExportRedemptionBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exported_object** | **String** | The type of object to be exported. | [default to 'redemption'] | +| **parameters** | [**ExportRedemptionBaseParameters**](ExportRedemptionBaseParameters.md) | | [optional] | + diff --git a/docs/ExportRedemptionBaseParameters.md b/docs/ExportRedemptionBaseParameters.md new file mode 100644 index 00000000..98d13108 --- /dev/null +++ b/docs/ExportRedemptionBaseParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ExportRedemptionBaseParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | [**ExportRedemptionOrder**](ExportRedemptionOrder.md) | | [optional] | +| **fields** | [**Array<ExportRedemptionFields>**](ExportRedemptionFields.md) | Array of strings containing the data in the export. These fields define the headers in the CSV file. | [optional] | +| **filters** | **Object** | Allowed additional properties must start with \"metadata.\" | [optional] | + diff --git a/docs/ExportRedemptionFields.md b/docs/ExportRedemptionFields.md new file mode 100644 index 00000000..7f4812ba --- /dev/null +++ b/docs/ExportRedemptionFields.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportRedemptionFields + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportRedemptionFilters.md b/docs/ExportRedemptionFilters.md new file mode 100644 index 00000000..b3b72bb1 --- /dev/null +++ b/docs/ExportRedemptionFilters.md @@ -0,0 +1,25 @@ +# VoucherifySdk::ExportRedemptionFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **object** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **date** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **voucher_code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **campaign** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **promotion_tier_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_source_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_name** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **tracking_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **order_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **gift_amount** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **loyalty_points** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **result** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **failure_code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **failure_message** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **metadata** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ExportRedemptionOrder.md b/docs/ExportRedemptionOrder.md new file mode 100644 index 00000000..d96b826b --- /dev/null +++ b/docs/ExportRedemptionOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportRedemptionOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportRedemptionScheduled.md b/docs/ExportRedemptionScheduled.md new file mode 100644 index 00000000..df47dbd8 --- /dev/null +++ b/docs/ExportRedemptionScheduled.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportRedemptionScheduled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'redemption'] | +| **parameters** | [**ExportRedemptionBaseParameters**](ExportRedemptionBaseParameters.md) | | [optional] | + diff --git a/docs/ExportScheduledBase.md b/docs/ExportScheduledBase.md new file mode 100644 index 00000000..164458b8 --- /dev/null +++ b/docs/ExportScheduledBase.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ExportScheduledBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | + diff --git a/docs/ExportVoucher.md b/docs/ExportVoucher.md new file mode 100644 index 00000000..da9dc705 --- /dev/null +++ b/docs/ExportVoucher.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher'] | +| **parameters** | [**ExportVoucherBaseParameters**](ExportVoucherBaseParameters.md) | | [optional] | + diff --git a/docs/ExportVoucherBase.md b/docs/ExportVoucherBase.md new file mode 100644 index 00000000..c86a5f2f --- /dev/null +++ b/docs/ExportVoucherBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ExportVoucherBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher'] | +| **parameters** | [**ExportVoucherBaseParameters**](ExportVoucherBaseParameters.md) | | [optional] | + diff --git a/docs/ExportVoucherBaseParameters.md b/docs/ExportVoucherBaseParameters.md new file mode 100644 index 00000000..d38fd813 --- /dev/null +++ b/docs/ExportVoucherBaseParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ExportVoucherBaseParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | [**ExportVoucherOrder**](ExportVoucherOrder.md) | | [optional] | +| **fields** | [**Array<ExportVoucherFields>**](ExportVoucherFields.md) | Array of strings containing the data in the export. These fields define the headers in the CSV file. | [optional] | +| **filters** | **Object** | Allowed additional properties must start with \"metadata.\" or \"redemption.\" | [optional] | + diff --git a/docs/ExportVoucherFields.md b/docs/ExportVoucherFields.md new file mode 100644 index 00000000..871ac22c --- /dev/null +++ b/docs/ExportVoucherFields.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportVoucherFields + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportVoucherFilters.md b/docs/ExportVoucherFilters.md new file mode 100644 index 00000000..72040827 --- /dev/null +++ b/docs/ExportVoucherFilters.md @@ -0,0 +1,38 @@ +# VoucherifySdk::ExportVoucherFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **voucher_type** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **value** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **discount_type** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **campaign** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **category** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **start_date** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **expiration_date** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **gift_balance** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **loyalty_balance** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemption_quantity** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **redemption_count** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **active** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **qr_code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **bar_code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **metadata** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **is_referral_code** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **created_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **updated_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **validity_timeframe_interval** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **validity_timeframe_duration** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **validity_day_of_week** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **discount_amount_limit** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **campaign_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **additional_info** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **discount_unit_type** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **discount_unit_effect** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **customer_source_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ExportVoucherOrder.md b/docs/ExportVoucherOrder.md new file mode 100644 index 00000000..e7c8305d --- /dev/null +++ b/docs/ExportVoucherOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportVoucherOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportVoucherScheduled.md b/docs/ExportVoucherScheduled.md new file mode 100644 index 00000000..f6794723 --- /dev/null +++ b/docs/ExportVoucherScheduled.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportVoucherScheduled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher'] | +| **parameters** | [**ExportVoucherBaseParameters**](ExportVoucherBaseParameters.md) | | [optional] | + diff --git a/docs/ExportVoucherTransactions.md b/docs/ExportVoucherTransactions.md new file mode 100644 index 00000000..b868f47f --- /dev/null +++ b/docs/ExportVoucherTransactions.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportVoucherTransactions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher_transactions'] | +| **parameters** | [**LoyaltiesMembersTransactionsExportCreateRequestBodyParameters**](LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/ExportVoucherTransactionsBase.md b/docs/ExportVoucherTransactionsBase.md new file mode 100644 index 00000000..f0d0f4d1 --- /dev/null +++ b/docs/ExportVoucherTransactionsBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ExportVoucherTransactionsBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher_transactions'] | +| **parameters** | [**LoyaltiesMembersTransactionsExportCreateRequestBodyParameters**](LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/ExportVoucherTransactionsFields.md b/docs/ExportVoucherTransactionsFields.md new file mode 100644 index 00000000..2ad3ad05 --- /dev/null +++ b/docs/ExportVoucherTransactionsFields.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportVoucherTransactionsFields + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportVoucherTransactionsFilters.md b/docs/ExportVoucherTransactionsFilters.md new file mode 100644 index 00000000..39c07b5b --- /dev/null +++ b/docs/ExportVoucherTransactionsFilters.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ExportVoucherTransactionsFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **created_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **voucher_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **campaign_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ExportVoucherTransactionsOrder.md b/docs/ExportVoucherTransactionsOrder.md new file mode 100644 index 00000000..14efed7e --- /dev/null +++ b/docs/ExportVoucherTransactionsOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ExportVoucherTransactionsOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ExportVoucherTransactionsScheduled.md b/docs/ExportVoucherTransactionsScheduled.md new file mode 100644 index 00000000..3abd779d --- /dev/null +++ b/docs/ExportVoucherTransactionsScheduled.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportVoucherTransactionsScheduled + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher_transactions'] | +| **parameters** | [**LoyaltiesMembersTransactionsExportCreateRequestBodyParameters**](LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/ExportsApi.md b/docs/ExportsApi.md new file mode 100644 index 00000000..4a34df59 --- /dev/null +++ b/docs/ExportsApi.md @@ -0,0 +1,301 @@ +# VoucherifySdk::ExportsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_export**](ExportsApi.md#create_export) | **POST** /v1/exports | Create Export | +| [**delete_export**](ExportsApi.md#delete_export) | **DELETE** /v1/exports/{exportId} | Delete Export | +| [**download_export**](ExportsApi.md#download_export) | **GET** /v1/exports/{export_Id} | Download Export | +| [**get_export**](ExportsApi.md#get_export) | **GET** /v1/exports/{exportId} | Get Export | +| [**list_exports**](ExportsApi.md#list_exports) | **GET** /v1/exports | List Exports | + + +## create_export + +> create_export(opts) + +Create Export + +Create export object. The export can be any of the following types: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # Defaults If you only specify the object type in the request body without specifying the fields, the API will return the following fields per export object: # Fetching particular data sets Using the parameters body parameter, you can narrow down which fields to export and how to filter the results. The fields are an array of strings containing the data that you would like to export. These fields define the headers in the CSV file. The array can be a combintation of any of the following available fields: # Orders # Vouchers # Publications # Redemptions # Customers # Points Expirations # Gift Card Transactions # Loyalty Card Transactions + +### 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::ExportsApi.new +opts = { + exports_create_request_body: VoucherifySdk::ExportCustomerBase.new({exported_object: 'customer'}) # ExportsCreateRequestBody | Specify the details of the export that you would like to create. +} + +begin + # Create Export + result = api_instance.create_export(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ExportsApi->create_export: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exports_create_request_body** | [**ExportsCreateRequestBody**](ExportsCreateRequestBody.md) | Specify the details of the export that you would like to create. | [optional] | + +### Return type + +[**ExportsCreateResponseBody**](ExportsCreateResponseBody.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 + + +## delete_export + +> delete_export(export_id) + +Delete Export + +This method deletes a previously created export object. + +### 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::ExportsApi.new +export_id = 'export_id_example' # String | Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. + +begin + # Delete Export + api_instance.delete_export(export_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling ExportsApi->delete_export: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **export_id** | **String** | Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## download_export + +> String download_export(export_id, opts) + +Download Export + +Download the contents of the exported CSV file. 📘 Important notes **Base URL:** - https://download.voucherify.io (Europe) - https://us1.download.voucherify.io (US) - https://as1.download.voucherify.io (Asia) **Token:** Can be found within the result parameter of the Get Export method response. + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' + +api_instance = VoucherifySdk::ExportsApi.new +export_id = 'exp_ex6zq0x0EEa9S0N68QcqhxcQ' # String | Unique export object ID. +opts = { + token: 'token_example' # String | Token that was issued to the export, to get this token, get the export first +} + +begin + # Download Export + result = api_instance.download_export(export_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ExportsApi->download_export: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **export_id** | **String** | Unique export object ID. | | +| **token** | **String** | Token that was issued to the export, to get this token, get the export first | [optional] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/plain + + +## get_export + +> get_export(export_id) + +Get Export + +Retrieves the URL of the downloadable file, which was generated via the Create Export method. + +### 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::ExportsApi.new +export_id = 'export_id_example' # String | Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. + +begin + # Get Export + result = api_instance.get_export(export_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ExportsApi->get_export: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **export_id** | **String** | Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. | | + +### Return type + +[**ExportsGetResponseBody**](ExportsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_exports + +> list_exports(opts) + +List Exports + +List all exports. + +### 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::ExportsApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrderListExports::CREATED_AT # ParameterOrderListExports | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. +} + +begin + # List Exports + result = api_instance.list_exports(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ExportsApi->list_exports: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrderListExports**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | + +### Return type + +[**ExportsListResponseBody**](ExportsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/ExportsCreateRequestBody.md b/docs/ExportsCreateRequestBody.md new file mode 100644 index 00000000..732c1d76 --- /dev/null +++ b/docs/ExportsCreateRequestBody.md @@ -0,0 +1,59 @@ +# VoucherifySdk::ExportsCreateRequestBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ExportsCreateRequestBody.openapi_one_of +# => +# [ +# :'ExportCustomerBase', +# :'ExportOrderBase', +# :'ExportPointsExpirationBase', +# :'ExportPublicationBase', +# :'ExportRedemptionBase', +# :'ExportVoucherBase', +# :'ExportVoucherTransactionsBase' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ExportsCreateRequestBody.build(data) +# => # + +VoucherifySdk::ExportsCreateRequestBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ExportCustomerBase` +- `ExportOrderBase` +- `ExportPointsExpirationBase` +- `ExportPublicationBase` +- `ExportRedemptionBase` +- `ExportVoucherBase` +- `ExportVoucherTransactionsBase` +- `nil` (if no type matches) + diff --git a/docs/ExportsCreateResponseBody.md b/docs/ExportsCreateResponseBody.md new file mode 100644 index 00000000..7392df22 --- /dev/null +++ b/docs/ExportsCreateResponseBody.md @@ -0,0 +1,59 @@ +# VoucherifySdk::ExportsCreateResponseBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ExportsCreateResponseBody.openapi_one_of +# => +# [ +# :'ExportCustomerScheduled', +# :'ExportOrderScheduled', +# :'ExportPointsExpirationScheduled', +# :'ExportPublicationScheduled', +# :'ExportRedemptionScheduled', +# :'ExportVoucherScheduled', +# :'ExportVoucherTransactionsScheduled' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ExportsCreateResponseBody.build(data) +# => # + +VoucherifySdk::ExportsCreateResponseBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ExportCustomerScheduled` +- `ExportOrderScheduled` +- `ExportPointsExpirationScheduled` +- `ExportPublicationScheduled` +- `ExportRedemptionScheduled` +- `ExportVoucherScheduled` +- `ExportVoucherTransactionsScheduled` +- `nil` (if no type matches) + diff --git a/docs/ExportsGetResponseBody.md b/docs/ExportsGetResponseBody.md new file mode 100644 index 00000000..99f2fc70 --- /dev/null +++ b/docs/ExportsGetResponseBody.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ExportsGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | [**ExportBaseResult**](ExportBaseResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher_transactions'] | +| **parameters** | [**LoyaltiesMembersTransactionsExportCreateRequestBodyParameters**](LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/ExportsListResponseBody.md b/docs/ExportsListResponseBody.md new file mode 100644 index 00000000..fdd9830b --- /dev/null +++ b/docs/ExportsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ExportsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about exports. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of exports. | [default to 'exports'] | +| **exports** | [**Array<Export>**](Export.md) | An array of export objects. | | +| **total** | **Integer** | Total number of exports. | | + diff --git a/docs/FieldConditions.md b/docs/FieldConditions.md new file mode 100644 index 00000000..b07f51d6 --- /dev/null +++ b/docs/FieldConditions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::FieldConditions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FiltersCondition**](FiltersCondition.md) | | [optional] | + diff --git a/docs/FilterConditionsString.md b/docs/FilterConditionsString.md new file mode 100644 index 00000000..f3a303e1 --- /dev/null +++ b/docs/FilterConditionsString.md @@ -0,0 +1,15 @@ +# VoucherifySdk::FilterConditionsString + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **_in** | **Array<String>** | Array of resource values that should be included in the results. (multiple values) | [optional] | +| **not_in** | **Array<String>** | Array of resource values that should be included in the results. (multiple values) | [optional] | +| **is** | **String** | Value is exactly this value. (single value) | [optional] | +| **is_not** | **String** | Results omit this value. (single value) | [optional] | +| **has_value** | **String** | Value is NOT null. The value for this parameter is an empty string. | [optional] | +| **is_unknown** | **String** | Value is null. The value for this parameter is an empty string. | [optional] | +| **starts_with** | **String** | Value starts with the specified string. | [optional] | +| **ends_with** | **String** | Value ends with the specified string. | [optional] | + diff --git a/docs/FiltersCondition.md b/docs/FiltersCondition.md new file mode 100644 index 00000000..3f13f85a --- /dev/null +++ b/docs/FiltersCondition.md @@ -0,0 +1,32 @@ +# VoucherifySdk::FiltersCondition + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **_in** | [**Any**](Any.md) | | [optional] | +| **not_in** | [**Any**](Any.md) | | [optional] | +| **is** | [**Any**](Any.md) | | [optional] | +| **is_days_ago** | [**Any**](Any.md) | | [optional] | +| **is_days_in_future** | [**Any**](Any.md) | | [optional] | +| **is_not** | [**Any**](Any.md) | | [optional] | +| **has_value** | [**Any**](Any.md) | | [optional] | +| **is_unknown** | [**Any**](Any.md) | | [optional] | +| **contains** | [**Any**](Any.md) | | [optional] | +| **not_contain** | [**Any**](Any.md) | | [optional] | +| **starts_with** | [**Any**](Any.md) | | [optional] | +| **ends_with** | [**Any**](Any.md) | | [optional] | +| **more_than** | [**Any**](Any.md) | | [optional] | +| **less_than** | [**Any**](Any.md) | | [optional] | +| **more_than_ago** | [**Any**](Any.md) | | [optional] | +| **less_than_ago** | [**Any**](Any.md) | | [optional] | +| **more_than_future** | [**Any**](Any.md) | | [optional] | +| **less_than_future** | [**Any**](Any.md) | | [optional] | +| **more_than_equal** | [**Any**](Any.md) | | [optional] | +| **less_than_equal** | [**Any**](Any.md) | | [optional] | +| **after** | [**Any**](Any.md) | | [optional] | +| **before** | [**Any**](Any.md) | | [optional] | +| **count** | [**Any**](Any.md) | | [optional] | +| **count_less** | [**Any**](Any.md) | | [optional] | +| **count_more** | [**Any**](Any.md) | | [optional] | + diff --git a/docs/Gift.md b/docs/Gift.md new file mode 100644 index 00000000..b89a44d3 --- /dev/null +++ b/docs/Gift.md @@ -0,0 +1,10 @@ +# VoucherifySdk::Gift + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **amount** | **Float** | Total gift card income over the lifetime of the card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | | +| **balance** | **Float** | Available funds. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | | +| **effect** | **String** | Defines how the credits are applied to the customer's order. | [optional] | + diff --git a/docs/GiftCampaignVoucher.md b/docs/GiftCampaignVoucher.md new file mode 100644 index 00000000..16580c50 --- /dev/null +++ b/docs/GiftCampaignVoucher.md @@ -0,0 +1,11 @@ +# VoucherifySdk::GiftCampaignVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of voucher. | [default to 'GIFT_VOUCHER'] | +| **gift** | [**Gift**](Gift.md) | | | +| **redemption** | [**CampaignLoyaltyVoucherRedemption**](CampaignLoyaltyVoucherRedemption.md) | | [optional] | +| **code_config** | [**CodeConfig**](CodeConfig.md) | | [optional] | + diff --git a/docs/GiveawayCampaignVoucher.md b/docs/GiveawayCampaignVoucher.md new file mode 100644 index 00000000..c1e92826 --- /dev/null +++ b/docs/GiveawayCampaignVoucher.md @@ -0,0 +1,12 @@ +# VoucherifySdk::GiveawayCampaignVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of voucher. | [default to 'DISCOUNT_VOUCHER'] | +| **discount** | [**Discount**](Discount.md) | | | +| **code_config** | [**CodeConfig**](CodeConfig.md) | | [optional] | +| **redemption** | [**CampaignLoyaltyVoucherRedemption**](CampaignLoyaltyVoucherRedemption.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | + diff --git a/docs/InapplicableTo.md b/docs/InapplicableTo.md new file mode 100644 index 00000000..78548a4d --- /dev/null +++ b/docs/InapplicableTo.md @@ -0,0 +1,21 @@ +# VoucherifySdk::InapplicableTo + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | This object stores information about the product collection. | | +| **id** | **String** | Unique product collection ID assigned by Voucherify. | | +| **source_id** | **String** | The source ID from your inventory system. | [optional] | +| **product_id** | **String** | Parent product's unique ID assigned by Voucherify. | [optional] | +| **product_source_id** | **String** | Parent product's source ID from your inventory system. | [optional] | +| **strict** | **Boolean** | | | +| **price** | **Float** | New fixed price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 price is written as 1000. In case of the fixed price being calculated by the formula, i.e. the price_formula parameter is present in the fixed price definition, this value becomes the fallback value. Such that in a case where the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed price. | [optional] | +| **price_formula** | **Float** | Formula used to calculate the discounted price of an item. | [optional] | +| **effect** | [**ApplicableToEffect**](ApplicableToEffect.md) | | | +| **quantity_limit** | **Integer** | The maximum number of units allowed to be discounted per order line item. | [optional] | +| **aggregated_quantity_limit** | **Integer** | The maximum number of units allowed to be discounted combined across all matched order line items. | [optional] | +| **amount_limit** | **Integer** | Upper limit allowed to be applied as a discount per order line item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600. | [optional] | +| **aggregated_amount_limit** | **Integer** | Maximum discount amount per order. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount on the entire order is written as 600. This value is definable for the following discount effects: - `APPLY_TO_ITEMS` (each item subtotal is discounted equally) - `APPLY_TO_ITEMS_BY_QUANTITY` (each unit of matched products has the same discount value) | [optional] | +| **order_item_indices** | **Array<Integer>** | | [optional] | + diff --git a/docs/InapplicableToResultList.md b/docs/InapplicableToResultList.md new file mode 100644 index 00000000..96c69254 --- /dev/null +++ b/docs/InapplicableToResultList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::InapplicableToResultList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **data** | [**Array<InapplicableTo>**](InapplicableTo.md) | Contains array of items to which the discount cannot apply. | | +| **total** | **Integer** | Total number of objects defining included products, SKUs, or product collections. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'list'] | +| **data_ref** | **String** | The type of object represented by JSON. | [default to 'data'] | + diff --git a/docs/Junction.md b/docs/Junction.md new file mode 100644 index 00000000..9065115a --- /dev/null +++ b/docs/Junction.md @@ -0,0 +1,7 @@ +# VoucherifySdk::Junction + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ListPublicationsItemBase.md b/docs/ListPublicationsItemBase.md new file mode 100644 index 00000000..6f00b716 --- /dev/null +++ b/docs/ListPublicationsItemBase.md @@ -0,0 +1,17 @@ +# VoucherifySdk::ListPublicationsItemBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique publication ID, assigned by Voucherify. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `publication`. | [default to 'publication'] | +| **created_at** | **Time** | Timestamp representing the date and time when the publication was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the customer receiving the publication. | | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | | +| **channel** | **String** | How the publication was originated. It can be your own custom channel or an example value provided here. | | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. | | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **vouchers_id** | **Array<String>** | Contains the unique internal voucher ID that was assigned by Voucherify. | | + diff --git a/docs/ListPublicationsItemInvalid.md b/docs/ListPublicationsItemInvalid.md new file mode 100644 index 00000000..9b17fd25 --- /dev/null +++ b/docs/ListPublicationsItemInvalid.md @@ -0,0 +1,20 @@ +# VoucherifySdk::ListPublicationsItemInvalid + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique publication ID, assigned by Voucherify. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `publication`. | [default to 'publication'] | +| **created_at** | **Time** | Timestamp representing the date and time when the publication was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the customer receiving the publication. | | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | | +| **channel** | **String** | How the publication was originated. It can be your own custom channel or an example value provided here. | | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. | | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **vouchers_id** | **Array<String>** | Contains the unique internal voucher ID that was assigned by Voucherify. | | +| **result** | **String** | Status of the publication attempt. | [default to 'FAILURE'] | +| **failure_code** | **String** | Generic reason as to why the create publication operation failed. | [optional] | +| **failure_message** | **String** | This parameter will provide more expanded reason as to why the create publication operation failed. | [optional] | + diff --git a/docs/ListPublicationsItemValidMultipleVouchers.md b/docs/ListPublicationsItemValidMultipleVouchers.md new file mode 100644 index 00000000..7582ecc2 --- /dev/null +++ b/docs/ListPublicationsItemValidMultipleVouchers.md @@ -0,0 +1,19 @@ +# VoucherifySdk::ListPublicationsItemValidMultipleVouchers + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique publication ID, assigned by Voucherify. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `publication`. | [default to 'publication'] | +| **created_at** | **Time** | Timestamp representing the date and time when the publication was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the customer receiving the publication. | | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | | +| **channel** | **String** | How the publication was originated. It can be your own custom channel or an example value provided here. | | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. | | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **vouchers_id** | **Array<String>** | Contains the unique internal voucher ID that was assigned by Voucherify. | | +| **result** | **String** | Status of the publication attempt. | [default to 'SUCCESS'] | +| **vouchers** | **Array<String>** | Contains the unique voucher codes that was assigned by Voucherify. | | + diff --git a/docs/ListPublicationsItemValidSingleVoucher.md b/docs/ListPublicationsItemValidSingleVoucher.md new file mode 100644 index 00000000..2293f3ae --- /dev/null +++ b/docs/ListPublicationsItemValidSingleVoucher.md @@ -0,0 +1,19 @@ +# VoucherifySdk::ListPublicationsItemValidSingleVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique publication ID, assigned by Voucherify. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `publication`. | [default to 'publication'] | +| **created_at** | **Time** | Timestamp representing the date and time when the publication was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the customer receiving the publication. | | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | | +| **channel** | **String** | How the publication was originated. It can be your own custom channel or an example value provided here. | | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. | | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **vouchers_id** | **Array<String>** | Contains the unique internal voucher ID that was assigned by Voucherify. | | +| **result** | **String** | Status of the publication attempt. | [default to 'SUCCESS'] | +| **voucher** | [**ListPublicationsItemVoucher**](ListPublicationsItemVoucher.md) | | | + diff --git a/docs/ListPublicationsItemVoucher.md b/docs/ListPublicationsItemVoucher.md new file mode 100644 index 00000000..6654a06c --- /dev/null +++ b/docs/ListPublicationsItemVoucher.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ListPublicationsItemVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | Voucher code. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'voucher'] | +| **campaign** | **String** | Campaign name | | +| **gift** | [**Gift**](Gift.md) | | [optional] | +| **loyalty_card** | **Object** | Defines the loyalty card details. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | + diff --git a/docs/LoyaltiesApi.md b/docs/LoyaltiesApi.md new file mode 100644 index 00000000..a09a0d81 --- /dev/null +++ b/docs/LoyaltiesApi.md @@ -0,0 +1,1643 @@ +# VoucherifySdk::LoyaltiesApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_in_bulk_loyalty_tiers**](LoyaltiesApi.md#create_in_bulk_loyalty_tiers) | **POST** /v1/loyalties/{campaignId}/tiers | Create loyalty tiers | +| [**delete_earning_rule**](LoyaltiesApi.md#delete_earning_rule) | **DELETE** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId} | Delete Earning Rule | +| [**delete_loyalty_program**](LoyaltiesApi.md#delete_loyalty_program) | **DELETE** /v1/loyalties/{campaignId} | Delete Loyalty Campaign | +| [**delete_reward_assignment1**](LoyaltiesApi.md#delete_reward_assignment1) | **DELETE** /v1/loyalties/{campaignId}/rewards/{assignmentId} | Delete Reward Assignment | +| [**disable_earning_rule**](LoyaltiesApi.md#disable_earning_rule) | **POST** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/disable | Disable Earning Rule | +| [**enable_earning_rule**](LoyaltiesApi.md#enable_earning_rule) | **POST** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/enable | Enable Earning Rule | +| [**export_loyalty_card_transactions**](LoyaltiesApi.md#export_loyalty_card_transactions) | **POST** /v1/loyalties/members/{memberId}/transactions/export | Export Loyalty Card Transactions | +| [**export_loyalty_card_transactions1**](LoyaltiesApi.md#export_loyalty_card_transactions1) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/transactions/export | Export Loyalty Card Transactions | +| [**get_earning_rule**](LoyaltiesApi.md#get_earning_rule) | **GET** /v1/loyalties/{campaignId}/earning-rules/{earningRuleId} | Get Earning Rule | +| [**get_loyalty_tier**](LoyaltiesApi.md#get_loyalty_tier) | **GET** /v1/loyalties/{campaignId}/tiers/{loyaltyTierId} | Get Loyalty Tier | +| [**get_reward_assignment1**](LoyaltiesApi.md#get_reward_assignment1) | **GET** /v1/loyalties/{campaignId}/reward-assignments/{assignmentId} | Get Reward Assignment | +| [**get_reward_assignment2**](LoyaltiesApi.md#get_reward_assignment2) | **GET** /v1/loyalties/{campaignId}/rewards/{assignmentId} | Get Reward Assignment | +| [**get_reward_details**](LoyaltiesApi.md#get_reward_details) | **GET** /v1/loyalties/{campaignId}/reward-assignments/{assignmentId}/reward | Get Reward Details | +| [**list_loyalty_card_transactions**](LoyaltiesApi.md#list_loyalty_card_transactions) | **GET** /v1/loyalties/members/{memberId}/transactions | List Loyalty Card Transactions | +| [**list_loyalty_card_transactions1**](LoyaltiesApi.md#list_loyalty_card_transactions1) | **GET** /v1/loyalties/{campaignId}/members/{memberId}/transactions | List Loyalty Card Transactions | +| [**list_loyalty_tier_earning_rules**](LoyaltiesApi.md#list_loyalty_tier_earning_rules) | **GET** /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/earning-rules | List Loyalty Tier Earning Rules | +| [**list_loyalty_tier_rewards**](LoyaltiesApi.md#list_loyalty_tier_rewards) | **GET** /v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/rewards | List Loyalty Tier Rewards | +| [**list_loyalty_tiers**](LoyaltiesApi.md#list_loyalty_tiers) | **GET** /v1/loyalties/{campaignId}/tiers | List Loyalty Tiers | +| [**list_member_loyalty_tier**](LoyaltiesApi.md#list_member_loyalty_tier) | **GET** /v1/loyalties/members/{memberId}/tiers | List Member's Loyalty Tiers | +| [**list_member_rewards**](LoyaltiesApi.md#list_member_rewards) | **GET** /v1/loyalties/members/{memberId}/rewards | List Member Rewards | +| [**list_points_expiration**](LoyaltiesApi.md#list_points_expiration) | **GET** /v1/loyalties/{campaignId}/members/{memberId}/points-expiration | Get Points Expiration | +| [**redeem_reward**](LoyaltiesApi.md#redeem_reward) | **POST** /v1/loyalties/members/{memberId}/redemption | Redeem Reward | +| [**redeem_reward1**](LoyaltiesApi.md#redeem_reward1) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/redemption | Redeem Reward | +| [**transfer_points**](LoyaltiesApi.md#transfer_points) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/transfers | Transfer Loyalty Points | +| [**update_loyalty_card_balance**](LoyaltiesApi.md#update_loyalty_card_balance) | **POST** /v1/loyalties/members/{memberId}/balance | Add or Remove Loyalty Card Balance | +| [**update_loyalty_card_balance1**](LoyaltiesApi.md#update_loyalty_card_balance1) | **POST** /v1/loyalties/{campaignId}/members/{memberId}/balance | Add or Remove Loyalty Card Balance | + + +## create_in_bulk_loyalty_tiers + +> > create_in_bulk_loyalty_tiers(campaign_id, opts) + +Create loyalty tiers + +Creates loyalty tiers for desired campaign. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique loyalty campaign ID or name. +opts = { + loyalties_tiers_create_in_bulk_request_body_item: [VoucherifySdk::LoyaltiesTiersCreateInBulkRequestBodyItem.new({name: 'name_example', points: VoucherifySdk::LoyaltyTierBasePoints.new})] # Array | Provide tier definitions you want to add to existing loyalty campaign. +} + +begin + # Create loyalty tiers + result = api_instance.create_in_bulk_loyalty_tiers(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->create_in_bulk_loyalty_tiers: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique loyalty campaign ID or name. | | +| **loyalties_tiers_create_in_bulk_request_body_item** | [**Array<LoyaltiesTiersCreateInBulkRequestBodyItem>**](LoyaltiesTiersCreateInBulkRequestBodyItem.md) | Provide tier definitions you want to add to existing loyalty campaign. | [optional] | + +### Return type + +[**Array<LoyaltyTier>**](LoyaltyTier.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 + + +## delete_earning_rule + +> delete_earning_rule(campaign_id, earning_rule_id) + +Delete Earning Rule + +This method deletes an earning rule for a specific loyalty campaign. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +earning_rule_id = 'earning_rule_id_example' # String | A unique earning rule ID. + +begin + # Delete Earning Rule + api_instance.delete_earning_rule(campaign_id, earning_rule_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->delete_earning_rule: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **earning_rule_id** | **String** | A unique earning rule ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## delete_loyalty_program + +> delete_loyalty_program(campaign_id, opts) + +Delete Loyalty Campaign + +This method permanently deletes a loyalty campaign and all related loyalty cards. This action cannot be undone. Also, it immediately removes any redemptions on loyalty cards. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +opts = { + force: true # Boolean | If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with the same name. +} + +begin + # Delete Loyalty Campaign + result = api_instance.delete_loyalty_program(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->delete_loyalty_program: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **force** | **Boolean** | If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with the same name. | [optional] | + +### Return type + +[**LoyaltiesDeleteResponseBody**](LoyaltiesDeleteResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## delete_reward_assignment1 + +> delete_reward_assignment1(campaign_id, assignment_id) + +Delete Reward Assignment + +This method deletes a reward assignment for a particular loyalty campaign. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +assignment_id = 'assignment_id_example' # String | A unique reward assignment ID. + +begin + # Delete Reward Assignment + api_instance.delete_reward_assignment1(campaign_id, assignment_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->delete_reward_assignment1: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **assignment_id** | **String** | A unique reward assignment ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## disable_earning_rule + +> disable_earning_rule(campaign_id, earning_rule_id) + +Disable Earning Rule + +Disable an earning rule. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID or name. +earning_rule_id = 'earning_rule_id_example' # String | Unique earning rule ID. + +begin + # Disable Earning Rule + result = api_instance.disable_earning_rule(campaign_id, earning_rule_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->disable_earning_rule: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID or name. | | +| **earning_rule_id** | **String** | Unique earning rule ID. | | + +### Return type + +[**LoyaltiesEarningRulesDisableResponseBody**](LoyaltiesEarningRulesDisableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## enable_earning_rule + +> enable_earning_rule(campaign_id, earning_rule_id) + +Enable Earning Rule + +Enable an earning rule. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID or name. +earning_rule_id = 'earning_rule_id_example' # String | Unique earning rule ID. + +begin + # Enable Earning Rule + result = api_instance.enable_earning_rule(campaign_id, earning_rule_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->enable_earning_rule: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID or name. | | +| **earning_rule_id** | **String** | Unique earning rule ID. | | + +### Return type + +[**LoyaltiesEarningRulesEnableResponseBody**](LoyaltiesEarningRulesEnableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## export_loyalty_card_transactions + +> export_loyalty_card_transactions(member_id, opts) + +Export Loyalty Card Transactions + +Export transactions that are associated with point movements on a loyalty card. + +### 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::LoyaltiesApi.new +member_id = 'member_id_example' # String | A unique code identifying the loyalty card that you are looking to export transaction data for. +opts = { + loyalties_members_transactions_export_create_request_body: VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBody.new # LoyaltiesMembersTransactionsExportCreateRequestBody | Specify the parameters and filters for the transaction export. +} + +begin + # Export Loyalty Card Transactions + result = api_instance.export_loyalty_card_transactions(member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->export_loyalty_card_transactions: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **member_id** | **String** | A unique code identifying the loyalty card that you are looking to export transaction data for. | | +| **loyalties_members_transactions_export_create_request_body** | [**LoyaltiesMembersTransactionsExportCreateRequestBody**](LoyaltiesMembersTransactionsExportCreateRequestBody.md) | Specify the parameters and filters for the transaction export. | [optional] | + +### Return type + +[**LoyaltiesMembersTransactionsExportCreateResponseBody**](LoyaltiesMembersTransactionsExportCreateResponseBody.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 + + +## export_loyalty_card_transactions1 + +> export_loyalty_card_transactions1(campaign_id, member_id, opts) + +Export Loyalty Card Transactions + +Export transactions that are associated with point movements on a loyalty card. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to export. +member_id = 'member_id_example' # String | A unique code identifying the loyalty card that you are looking to export transaction data for. +opts = { + loyalties_members_transactions_export_create_request_body: VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBody.new # LoyaltiesMembersTransactionsExportCreateRequestBody | Specify the parameters and filters for the transaction export. +} + +begin + # Export Loyalty Card Transactions + result = api_instance.export_loyalty_card_transactions1(campaign_id, member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->export_loyalty_card_transactions1: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to export. | | +| **member_id** | **String** | A unique code identifying the loyalty card that you are looking to export transaction data for. | | +| **loyalties_members_transactions_export_create_request_body** | [**LoyaltiesMembersTransactionsExportCreateRequestBody**](LoyaltiesMembersTransactionsExportCreateRequestBody.md) | Specify the parameters and filters for the transaction export. | [optional] | + +### Return type + +[**LoyaltiesMembersTransactionsExportCreateResponseBody**](LoyaltiesMembersTransactionsExportCreateResponseBody.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 + + +## get_earning_rule + +> get_earning_rule(campaign_id, earning_rule_id) + +Get Earning Rule + +Retrieves an earning rule assigned to a campaign. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +earning_rule_id = 'earning_rule_id_example' # String | A unique earning rule ID. + +begin + # Get Earning Rule + result = api_instance.get_earning_rule(campaign_id, earning_rule_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->get_earning_rule: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **earning_rule_id** | **String** | A unique earning rule ID. | | + +### Return type + +[**LoyaltiesEarningRulesGetResponseBody**](LoyaltiesEarningRulesGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_loyalty_tier + +> get_loyalty_tier(campaign_id, loyalty_tier_id) + +Get Loyalty Tier + +Retrieve a loyalty tier from a loyalty campaign by the loyalty tier ID. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique loyalty campaign ID or name. +loyalty_tier_id = 'loyalty_tier_id_example' # String | Unique loyalty tier ID. + +begin + # Get Loyalty Tier + result = api_instance.get_loyalty_tier(campaign_id, loyalty_tier_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->get_loyalty_tier: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique loyalty campaign ID or name. | | +| **loyalty_tier_id** | **String** | Unique loyalty tier ID. | | + +### Return type + +[**LoyaltiesTiersGetResponseBody**](LoyaltiesTiersGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_reward_assignment1 + +> get_reward_assignment1(campaign_id, assignment_id) + +Get Reward Assignment + +Retrieve specific reward assignment. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +assignment_id = 'assignment_id_example' # String | Unique reward assignment ID. + +begin + # Get Reward Assignment + result = api_instance.get_reward_assignment1(campaign_id, assignment_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->get_reward_assignment1: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **assignment_id** | **String** | Unique reward assignment ID. | | + +### Return type + +[**LoyaltiesRewardAssignmentsGetResponseBody**](LoyaltiesRewardAssignmentsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_reward_assignment2 + +> get_reward_assignment2(campaign_id, assignment_id) + +Get Reward Assignment + +Retrieve specific reward assignment. 📘 Alternative endpoint This endpoint is an alternative to this endpoint. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +assignment_id = 'assignment_id_example' # String | A unique reward assignment ID. + +begin + # Get Reward Assignment + result = api_instance.get_reward_assignment2(campaign_id, assignment_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->get_reward_assignment2: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **assignment_id** | **String** | A unique reward assignment ID. | | + +### Return type + +[**LoyaltiesRewardsGetResponseBody**](LoyaltiesRewardsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_reward_details + +> get_reward_details(campaign_id, assignment_id) + +Get Reward Details + +Get reward details in the context of a loyalty campaign and reward assignment ID. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +assignment_id = 'assignment_id_example' # String | Unique reward assignment ID. + +begin + # Get Reward Details + result = api_instance.get_reward_details(campaign_id, assignment_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->get_reward_details: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **assignment_id** | **String** | Unique reward assignment ID. | | + +### Return type + +[**LoyaltiesRewardAssignmentsRewardGetResponseBody**](LoyaltiesRewardAssignmentsRewardGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_loyalty_card_transactions + +> list_loyalty_card_transactions(member_id, opts) + +List Loyalty Card Transactions + +Retrieve transaction data related to point movements for a specific loyalty card. + +### 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::LoyaltiesApi.new +member_id = 'member_id_example' # String | A unique code identifying the loyalty card that you are looking to retrieve transaction data for. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56 # Integer | Which page of results to return. +} + +begin + # List Loyalty Card Transactions + result = api_instance.list_loyalty_card_transactions(member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_loyalty_card_transactions: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **member_id** | **String** | A unique code identifying the loyalty card that you are looking to retrieve transaction data for. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | + +### Return type + +[**LoyaltiesMembersTransactionsListResponseBody**](LoyaltiesMembersTransactionsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_loyalty_card_transactions1 + +> list_loyalty_card_transactions1(campaign_id, member_id, opts) + +List Loyalty Card Transactions + +Retrieve transaction data related to point movements for a specific loyalty card. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to return. +member_id = 'member_id_example' # String | A unique code identifying the loyalty card that you are looking to retrieve transaction data for. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56 # Integer | Which page of results to return. +} + +begin + # List Loyalty Card Transactions + result = api_instance.list_loyalty_card_transactions1(campaign_id, member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_loyalty_card_transactions1: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to return. | | +| **member_id** | **String** | A unique code identifying the loyalty card that you are looking to retrieve transaction data for. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | + +### Return type + +[**LoyaltiesMembersTransactionsListResponseBody**](LoyaltiesMembersTransactionsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_loyalty_tier_earning_rules + +> list_loyalty_tier_earning_rules(campaign_id, loyalty_tier_id, opts) + +List Loyalty Tier Earning Rules + +Retrieve available earning rules for a given tier and the calculation method for earning points. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID or name. +loyalty_tier_id = 'loyalty_tier_id_example' # String | Unique loyalty tier ID. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56 # Integer | Which page of results to return. +} + +begin + # List Loyalty Tier Earning Rules + result = api_instance.list_loyalty_tier_earning_rules(campaign_id, loyalty_tier_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_loyalty_tier_earning_rules: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID or name. | | +| **loyalty_tier_id** | **String** | Unique loyalty tier ID. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | + +### Return type + +[**LoyaltiesTiersEarningRulesListResponseBody**](LoyaltiesTiersEarningRulesListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_loyalty_tier_rewards + +> list_loyalty_tier_rewards(campaign_id, loyalty_tier_id) + +List Loyalty Tier Rewards + +Get available rewards for a given tier. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID or name. +loyalty_tier_id = 'loyalty_tier_id_example' # String | Unique loyalty tier ID. + +begin + # List Loyalty Tier Rewards + result = api_instance.list_loyalty_tier_rewards(campaign_id, loyalty_tier_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_loyalty_tier_rewards: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID or name. | | +| **loyalty_tier_id** | **String** | Unique loyalty tier ID. | | + +### Return type + +[**LoyaltiesTiersRewardsListResponseBody**](LoyaltiesTiersRewardsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_loyalty_tiers + +> list_loyalty_tiers(campaign_id, opts) + +List Loyalty Tiers + +Retrieve a list of loyalty tiers which were added to the loyalty program. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique loyalty campaign ID or name. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + order: VoucherifySdk::ParameterOrderListLoyaltyTiers::CREATED_AT # ParameterOrderListLoyaltyTiers | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. +} + +begin + # List Loyalty Tiers + result = api_instance.list_loyalty_tiers(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_loyalty_tiers: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique loyalty campaign ID or name. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **order** | [**ParameterOrderListLoyaltyTiers**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | + +### Return type + +[**LoyaltiesTiersListResponseBody**](LoyaltiesTiersListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_member_loyalty_tier + +> list_member_loyalty_tier(member_id) + +List Member's Loyalty Tiers + +Retrieve member tiers using the loyalty card ID. + +### 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::LoyaltiesApi.new +member_id = 'member_id_example' # String | Unique loyalty card assigned to a particular customer. + +begin + # List Member's Loyalty Tiers + result = api_instance.list_member_loyalty_tier(member_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_member_loyalty_tier: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **member_id** | **String** | Unique loyalty card assigned to a particular customer. | | + +### Return type + +[**LoyaltiesMembersTiersListResponseBody**](LoyaltiesMembersTiersListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_member_rewards + +> list_member_rewards(member_id, opts) + +List Member Rewards + +Retrieves the list of rewards that the given customer (identified by member_id, which is a loyalty card assigned to a particular customer) **can get in exchange for loyalty points**. You can use the affordable_only parameter to limit the results to rewards that the customer can actually afford (only rewards whose price in points is not higher than the loyalty points balance on a loyalty card). Please note that rewards that are disabled (i.e. set to Not Available in the Dashboard) for a given loyalty tier reward mapping will not be returned in this endpoint. + +### 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::LoyaltiesApi.new +member_id = 'member_id_example' # String | Unique loyalty card assigned to a particular customer. +opts = { + affordable_only: true # Boolean | Limit the results to rewards that the customer can actually afford (only rewards whose price in points is not higher than the loyalty points balance on a loyalty card). Set this flag to true to return rewards which the customer can actually afford. +} + +begin + # List Member Rewards + result = api_instance.list_member_rewards(member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_member_rewards: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **member_id** | **String** | Unique loyalty card assigned to a particular customer. | | +| **affordable_only** | **Boolean** | Limit the results to rewards that the customer can actually afford (only rewards whose price in points is not higher than the loyalty points balance on a loyalty card). Set this flag to true to return rewards which the customer can actually afford. | [optional] | + +### Return type + +[**LoyaltiesMembersRewardsListResponseBody**](LoyaltiesMembersRewardsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_points_expiration + +> list_points_expiration(campaign_id, member_id, opts) + +Get Points Expiration + +Retrieve loyalty point expiration buckets for a given loyalty card. Expired point buckets are not returned in this endpoint. You can use the Exports API to retrieve a list of both ACTIVE and EXPIRED point buckets. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. +member_id = 'member_id_example' # String | Loyalty card code. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56 # Integer | Which page of results to return. +} + +begin + # Get Points Expiration + result = api_instance.list_points_expiration(campaign_id, member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->list_points_expiration: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. | | +| **member_id** | **String** | Loyalty card code. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | + +### Return type + +[**LoyaltiesMembersPointsExpirationListResponseBody**](LoyaltiesMembersPointsExpirationListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## redeem_reward + +> redeem_reward(member_id, opts) + +Redeem Reward + + 📘 Alternative endpoint This endpoint is an alternative to this endpoint. The URL was re-designed to allow you to redeem a reward without having to provide the campaignId as a path parameter. + +### 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::LoyaltiesApi.new +member_id = 'member_id_example' # String | Unique loyalty card assigned to a particular customer. +opts = { + loyalties_members_redemption_redeem_request_body: VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBody.new # LoyaltiesMembersRedemptionRedeemRequestBody | Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. +} + +begin + # Redeem Reward + result = api_instance.redeem_reward(member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->redeem_reward: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **member_id** | **String** | Unique loyalty card assigned to a particular customer. | | +| **loyalties_members_redemption_redeem_request_body** | [**LoyaltiesMembersRedemptionRedeemRequestBody**](LoyaltiesMembersRedemptionRedeemRequestBody.md) | Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. | [optional] | + +### Return type + +[**LoyaltiesMembersRedemptionRedeemResponseBody**](LoyaltiesMembersRedemptionRedeemResponseBody.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 + + +## redeem_reward1 + +> redeem_reward1(campaign_id, member_id, opts) + +Redeem Reward + +Exchange points from a loyalty card for a specified reward. This API method returns an assigned award in the response. It means that if a requesting customer gets a coupon code with a discount for the next order, that discount code will be visible in response as part of the reward object definition. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID. +member_id = 'member_id_example' # String | A code that identifies the loyalty card. +opts = { + loyalties_members_redemption_redeem_request_body: VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBody.new # LoyaltiesMembersRedemptionRedeemRequestBody | Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. +} + +begin + # Redeem Reward + result = api_instance.redeem_reward1(campaign_id, member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->redeem_reward1: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID. | | +| **member_id** | **String** | A code that identifies the loyalty card. | | +| **loyalties_members_redemption_redeem_request_body** | [**LoyaltiesMembersRedemptionRedeemRequestBody**](LoyaltiesMembersRedemptionRedeemRequestBody.md) | Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. | [optional] | + +### Return type + +[**LoyaltiesMembersRedemptionRedeemResponseBody**](LoyaltiesMembersRedemptionRedeemResponseBody.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 + + +## transfer_points + +> transfer_points(campaign_id, member_id, opts) + +Transfer Loyalty Points + +Transfer points between different loyalty cards. You need to provide the campaign ID and the loyalty card ID you want the points to be transferred to as path parameters in the URL. In the request body, you provide the loyalty cards you want the points to be transferred from and the number of points to transfer from each card. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | A unique identifier of the loyalty campaign containing the voucher to which the loyalty points will be sent (destination). +member_id = 'member_id_example' # String | A unique code identifying the loyalty card to which the user wants to transfer loyalty points (destination). +opts = { + loyalties_transfer_points: [VoucherifySdk::LoyaltiesTransferPoints.new({code: 'code_example', points: 37, source_id: 'source_id_example'})] # Array | Provide the loyalty cards you want the points to be transferred from and the number of points to transfer from each card. +} + +begin + # Transfer Loyalty Points + result = api_instance.transfer_points(campaign_id, member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->transfer_points: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | A unique identifier of the loyalty campaign containing the voucher to which the loyalty points will be sent (destination). | | +| **member_id** | **String** | A unique code identifying the loyalty card to which the user wants to transfer loyalty points (destination). | | +| **loyalties_transfer_points** | [**Array<LoyaltiesTransferPoints>**](LoyaltiesTransferPoints.md) | Provide the loyalty cards you want the points to be transferred from and the number of points to transfer from each card. | [optional] | + +### Return type + +[**LoyaltiesMembersTransfersCreateResponseBody**](LoyaltiesMembersTransfersCreateResponseBody.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 + + +## update_loyalty_card_balance + +> update_loyalty_card_balance(member_id, opts) + +Add or Remove Loyalty Card Balance + +This method gives adds or removes balance to an existing loyalty card. The removal of points will consume the points that expire the soonest. 📘 Alternative endpoint This endpoint is an alternative to this endpoint. The URL was re-designed to allow you to add or remove loyalty card balance without having to provide the campaignId as a path parameter. + +### 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::LoyaltiesApi.new +member_id = 'member_id_example' # String | Unique loyalty card assigned to a particular customer. +opts = { + loyalties_members_balance_update_request_body: VoucherifySdk::LoyaltiesMembersBalanceUpdateRequestBody.new({points: 37}) # LoyaltiesMembersBalanceUpdateRequestBody | Specify the point adjustment along with the expiration mechanism. +} + +begin + # Add or Remove Loyalty Card Balance + result = api_instance.update_loyalty_card_balance(member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->update_loyalty_card_balance: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **member_id** | **String** | Unique loyalty card assigned to a particular customer. | | +| **loyalties_members_balance_update_request_body** | [**LoyaltiesMembersBalanceUpdateRequestBody**](LoyaltiesMembersBalanceUpdateRequestBody.md) | Specify the point adjustment along with the expiration mechanism. | [optional] | + +### Return type + +[**LoyaltiesMembersBalanceUpdateResponseBody**](LoyaltiesMembersBalanceUpdateResponseBody.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 + + +## update_loyalty_card_balance1 + +> update_loyalty_card_balance1(campaign_id, member_id, opts) + +Add or Remove Loyalty Card Balance + +This method adds or removes balance to an existing loyalty card. The removal of points will consume the points that expire the soonest. + +### 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::LoyaltiesApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID. +member_id = 'member_id_example' # String | A code that identifies the loyalty card. +opts = { + loyalties_members_balance_update_request_body: VoucherifySdk::LoyaltiesMembersBalanceUpdateRequestBody.new({points: 37}) # LoyaltiesMembersBalanceUpdateRequestBody | Specify the point adjustment along with the expiration mechanism. +} + +begin + # Add or Remove Loyalty Card Balance + result = api_instance.update_loyalty_card_balance1(campaign_id, member_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling LoyaltiesApi->update_loyalty_card_balance1: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID. | | +| **member_id** | **String** | A code that identifies the loyalty card. | | +| **loyalties_members_balance_update_request_body** | [**LoyaltiesMembersBalanceUpdateRequestBody**](LoyaltiesMembersBalanceUpdateRequestBody.md) | Specify the point adjustment along with the expiration mechanism. | [optional] | + +### Return type + +[**LoyaltiesMembersBalanceUpdateResponseBody**](LoyaltiesMembersBalanceUpdateResponseBody.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 + diff --git a/docs/LoyaltiesDeleteResponseBody.md b/docs/LoyaltiesDeleteResponseBody.md new file mode 100644 index 00000000..92e53353 --- /dev/null +++ b/docs/LoyaltiesDeleteResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::LoyaltiesDeleteResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/LoyaltiesEarningRulesDisableResponseBody.md b/docs/LoyaltiesEarningRulesDisableResponseBody.md new file mode 100644 index 00000000..f827b127 --- /dev/null +++ b/docs/LoyaltiesEarningRulesDisableResponseBody.md @@ -0,0 +1,23 @@ +# VoucherifySdk::LoyaltiesEarningRulesDisableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the earning rule object. | | +| **created_at** | **Time** | Timestamp representing the date and time when the earning rule was created in ISO 8601 format. | | +| **loyalty** | [**EarningRuleBaseLoyalty**](EarningRuleBaseLoyalty.md) | | | +| **event** | [**EarningRuleEvent**](EarningRuleEvent.md) | | [optional] | +| **custom_event** | [**EarningRuleBaseCustomEvent**](EarningRuleBaseCustomEvent.md) | | [optional] | +| **segment** | [**EarningRuleBaseSegment**](EarningRuleBaseSegment.md) | | [optional] | +| **source** | [**EarningRuleBaseSource**](EarningRuleBaseSource.md) | | | +| **object** | **String** | The type of object represented by JSON. Default is earning_rule. | [default to 'earning_rule'] | +| **automation_id** | **String** | For internal use by Voucherify. | | +| **start_date** | **String** | Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. | [optional] | +| **expiration_date** | **String** | Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. | [optional] | +| **validity_timeframe** | [**EarningRuleBaseValidityTimeframe**](EarningRuleBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. | | +| **active** | **Boolean** | A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. | [default to false] | + diff --git a/docs/LoyaltiesEarningRulesEnableResponseBody.md b/docs/LoyaltiesEarningRulesEnableResponseBody.md new file mode 100644 index 00000000..a14ce143 --- /dev/null +++ b/docs/LoyaltiesEarningRulesEnableResponseBody.md @@ -0,0 +1,23 @@ +# VoucherifySdk::LoyaltiesEarningRulesEnableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the earning rule object. | | +| **created_at** | **Time** | Timestamp representing the date and time when the earning rule was created in ISO 8601 format. | | +| **loyalty** | [**EarningRuleBaseLoyalty**](EarningRuleBaseLoyalty.md) | | | +| **event** | [**EarningRuleEvent**](EarningRuleEvent.md) | | [optional] | +| **custom_event** | [**EarningRuleBaseCustomEvent**](EarningRuleBaseCustomEvent.md) | | [optional] | +| **segment** | [**EarningRuleBaseSegment**](EarningRuleBaseSegment.md) | | [optional] | +| **source** | [**EarningRuleBaseSource**](EarningRuleBaseSource.md) | | | +| **object** | **String** | The type of object represented by JSON. Default is earning_rule. | [default to 'earning_rule'] | +| **automation_id** | **String** | For internal use by Voucherify. | | +| **start_date** | **String** | Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. | [optional] | +| **expiration_date** | **String** | Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. | [optional] | +| **validity_timeframe** | [**EarningRuleBaseValidityTimeframe**](EarningRuleBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. | | +| **active** | **Boolean** | A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. | [default to true] | + diff --git a/docs/LoyaltiesEarningRulesGetResponseBody.md b/docs/LoyaltiesEarningRulesGetResponseBody.md new file mode 100644 index 00000000..042cc4e7 --- /dev/null +++ b/docs/LoyaltiesEarningRulesGetResponseBody.md @@ -0,0 +1,24 @@ +# VoucherifySdk::LoyaltiesEarningRulesGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the earning rule object. | | +| **created_at** | **Time** | Timestamp representing the date and time when the earning rule was created in ISO 8601 format. | | +| **loyalty** | [**EarningRuleBaseLoyalty**](EarningRuleBaseLoyalty.md) | | | +| **event** | [**EarningRuleEvent**](EarningRuleEvent.md) | | [optional] | +| **custom_event** | [**EarningRuleBaseCustomEvent**](EarningRuleBaseCustomEvent.md) | | [optional] | +| **segment** | [**EarningRuleBaseSegment**](EarningRuleBaseSegment.md) | | [optional] | +| **source** | [**EarningRuleBaseSource**](EarningRuleBaseSource.md) | | | +| **object** | **String** | The type of object represented by JSON. Default is earning_rule. | [default to 'earning_rule'] | +| **automation_id** | **String** | For internal use by Voucherify. | | +| **start_date** | **String** | Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. | [optional] | +| **expiration_date** | **String** | Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. | [optional] | +| **validity_timeframe** | [**EarningRuleBaseValidityTimeframe**](EarningRuleBaseValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. | | +| **validation_rule_id** | **String** | A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. | | +| **active** | **Boolean** | A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. - `true` indicates an active earning rule - `false` indicates an inactive earning rule | | + diff --git a/docs/LoyaltiesLoyaltyTierReward.md b/docs/LoyaltiesLoyaltyTierReward.md new file mode 100644 index 00000000..3a07a199 --- /dev/null +++ b/docs/LoyaltiesLoyaltyTierReward.md @@ -0,0 +1,10 @@ +# VoucherifySdk::LoyaltiesLoyaltyTierReward + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward** | [**Reward**](Reward.md) | | | +| **assignment** | [**RewardAssignment**](RewardAssignment.md) | | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the loyalty tier reward. | [default to 'loyalty_tier_reward'] | + diff --git a/docs/LoyaltiesMembersBalanceUpdateRequestBody.md b/docs/LoyaltiesMembersBalanceUpdateRequestBody.md new file mode 100644 index 00000000..56e7bed3 --- /dev/null +++ b/docs/LoyaltiesMembersBalanceUpdateRequestBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::LoyaltiesMembersBalanceUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Incremental balance to be added to/subtracted from the loyalty card. - To add points: 100 - To subtract points, add a minus: -100 | | +| **expiration_type** | [**PointsExpirationTypes**](PointsExpirationTypes.md) | | [optional] | +| **expiration_date** | **Time** | Set expiration date for added points, i.e. `YYYY-MM-DD`. This parameter is required only when expiration_type is set to `CUSTOM_DATE`. | [optional] | +| **reason** | **String** | Reason for the transfer. | [optional] | +| **source_id** | **String** | The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. | [optional] | + diff --git a/docs/LoyaltiesMembersBalanceUpdateResponseBody.md b/docs/LoyaltiesMembersBalanceUpdateResponseBody.md new file mode 100644 index 00000000..81833fa9 --- /dev/null +++ b/docs/LoyaltiesMembersBalanceUpdateResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | The incremental points removed or added to the current balance on the loyalty card. | | +| **total** | **Integer** | The total of points accrued over the lifetime of the loyalty card. | | +| **balance** | **Integer** | The balance after adding/removing points. | | +| **type** | **String** | The type of voucher being modified. | | +| **object** | **String** | The type of object represented by JSON. Default is balance. | [default to 'balance'] | +| **related_object** | [**LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject**](LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject.md) | | | +| **operation_type** | **String** | | [optional] | + diff --git a/docs/LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject.md b/docs/LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject.md new file mode 100644 index 00000000..1889c089 --- /dev/null +++ b/docs/LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | The object being modified. | [default to 'voucher'] | +| **id** | **String** | Identifies the loyalty card that is being modified, this is the ID that was assigned by the Voucherify API. | | + diff --git a/docs/LoyaltiesMembersPointsExpirationListResponseBody.md b/docs/LoyaltiesMembersPointsExpirationListResponseBody.md new file mode 100644 index 00000000..c381b803 --- /dev/null +++ b/docs/LoyaltiesMembersPointsExpirationListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about loyalty points expiration buckets in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of loyalty points expiration bucket objects. | [default to 'data'] | +| **data** | [**Array<LoyaltiesMembersPointsExpirationListResponseBodyDataItem>**](LoyaltiesMembersPointsExpirationListResponseBodyDataItem.md) | Contains array of loyalty points expiration buckets. | | +| **total** | **Integer** | Total number of point expiration buckets. | | + diff --git a/docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItem.md b/docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItem.md new file mode 100644 index 00000000..9abaa3f8 --- /dev/null +++ b/docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItem.md @@ -0,0 +1,16 @@ +# VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique loyalty points bucket ID. | | +| **voucher_id** | **String** | Unique parent loyalty card ID. | | +| **campaign_id** | **String** | Unique parent campaign ID. | | +| **bucket** | [**LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket**](LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket.md) | | | +| **created_at** | **Time** | Timestamp representing the date and time when the loyalty points bucket object was created in ISO 8601 format. | | +| **status** | **String** | Loyalty points bucket point status. | | +| **expires_at** | **Time** | Date when the number of points defined in the bucket object are due to expire. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the loyalty points bucket object was updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the loyalty points bucket. | [default to 'loyalty_points_bucket'] | + diff --git a/docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket.md b/docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket.md new file mode 100644 index 00000000..99c31f16 --- /dev/null +++ b/docs/LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket.md @@ -0,0 +1,8 @@ +# VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total_points** | **Integer** | Total number of points in the loyalty points bucket. | | + diff --git a/docs/LoyaltiesMembersRedemptionRedeemRequestBody.md b/docs/LoyaltiesMembersRedemptionRedeemRequestBody.md new file mode 100644 index 00000000..6e254693 --- /dev/null +++ b/docs/LoyaltiesMembersRedemptionRedeemRequestBody.md @@ -0,0 +1,10 @@ +# VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward** | [**LoyaltiesMembersRedemptionRedeemRequestBodyReward**](LoyaltiesMembersRedemptionRedeemRequestBodyReward.md) | | [optional] | +| **order** | [**Order**](Order.md) | | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can send in the request body to check against vouchers requiring **redemption** metadata validation rules to be satisfied. The validation runs against rules that are defined through the <!-- [Create Validation Rules](https://docs.voucherify.io/reference/create-validation-rules) -->[Create Validation Rules](ref:create-validation-rules) endpoint or via the Dashboard; in the _Advanced Rule Builder_ &rarr; _Advanced_ &rarr; _Redemption metadata satisfy_ or _Basic Builder_ &rarr; _Attributes match_ &rarr; _REDEMPTION METADATA_. [Read more](https://support.voucherify.io/article/148-how-to-build-a-rule). | [optional] | + diff --git a/docs/LoyaltiesMembersRedemptionRedeemRequestBodyReward.md b/docs/LoyaltiesMembersRedemptionRedeemRequestBodyReward.md new file mode 100644 index 00000000..480db007 --- /dev/null +++ b/docs/LoyaltiesMembersRedemptionRedeemRequestBodyReward.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBodyReward + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward ID assigned by Voucherify. The reward must be assigned to the campaign in order for the user to be able to use the reward. | [optional] | +| **points** | **Integer** | The number of loyalty points that the user wants to spend in order to fulfill the order. The number of points cannot be higher than the current balance on the loyalty card. | [optional] | + diff --git a/docs/LoyaltiesMembersRedemptionRedeemResponseBody.md b/docs/LoyaltiesMembersRedemptionRedeemResponseBody.md new file mode 100644 index 00000000..f203e65b --- /dev/null +++ b/docs/LoyaltiesMembersRedemptionRedeemResponseBody.md @@ -0,0 +1,30 @@ +# VoucherifySdk::LoyaltiesMembersRedemptionRedeemResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | | +| **object** | **String** | The type of object represented by the JSON | [default to 'redemption'] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the redeeming customer. | | +| **tracking_id** | **String** | Hashed customer source ID. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the redemption. | | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **redemption** | **String** | Unique redemption ID of the parent redemption. | | +| **result** | **String** | Redemption result. | | +| **status** | **String** | Redemption status. | | +| **related_redemptions** | [**RedemptionRelatedRedemptions**](RedemptionRelatedRedemptions.md) | | [optional] | +| **failure_code** | **String** | If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. | [optional] | +| **failure_message** | **String** | If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. | [optional] | +| **order** | [**OrderCalculatedNoCustomerData**](OrderCalculatedNoCustomerData.md) | | | +| **channel** | [**RedemptionChannel**](RedemptionChannel.md) | | | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | | +| **related_object_type** | **String** | Defines the related object. | | +| **related_object_id** | **String** | Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | | +| **voucher** | [**Voucher**](Voucher.md) | | [optional] | +| **promotion_tier** | [**PromotionTier**](PromotionTier.md) | | [optional] | +| **reward** | [**RedemptionRewardResult**](RedemptionRewardResult.md) | | | +| **gift** | [**RedemptionGift**](RedemptionGift.md) | | [optional] | +| **loyalty_card** | [**RedemptionLoyaltyCard**](RedemptionLoyaltyCard.md) | | [optional] | + diff --git a/docs/LoyaltiesMembersRewardsListResponseBody.md b/docs/LoyaltiesMembersRewardsListResponseBody.md new file mode 100644 index 00000000..8379eb28 --- /dev/null +++ b/docs/LoyaltiesMembersRewardsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesMembersRewardsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of loyalty reward objects. | [default to 'data'] | +| **data** | [**Array<LoyaltiesMembersRewardsListResponseBodyDataItem>**](LoyaltiesMembersRewardsListResponseBodyDataItem.md) | Contains array of loyalty reward objects. | | +| **total** | **Integer** | Total number of loyalty reward objects. | | + diff --git a/docs/LoyaltiesMembersRewardsListResponseBodyDataItem.md b/docs/LoyaltiesMembersRewardsListResponseBodyDataItem.md new file mode 100644 index 00000000..5b3394e4 --- /dev/null +++ b/docs/LoyaltiesMembersRewardsListResponseBodyDataItem.md @@ -0,0 +1,10 @@ +# VoucherifySdk::LoyaltiesMembersRewardsListResponseBodyDataItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward** | [**Reward**](Reward.md) | | [optional] | +| **assignment** | [**RewardAssignment**](RewardAssignment.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. | [optional][default to 'loyalty_reward'] | + diff --git a/docs/LoyaltiesMembersTiersListResponseBody.md b/docs/LoyaltiesMembersTiersListResponseBody.md new file mode 100644 index 00000000..8f1b6c49 --- /dev/null +++ b/docs/LoyaltiesMembersTiersListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesMembersTiersListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about loyalty tiers in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of loyalty tier objects. | [default to 'data'] | +| **data** | [**Array<LoyaltyTier>**](LoyaltyTier.md) | | | +| **total** | **Integer** | Total number of loyalty tier objects. | | + diff --git a/docs/LoyaltiesMembersTransactionsExportCreateRequestBody.md b/docs/LoyaltiesMembersTransactionsExportCreateRequestBody.md new file mode 100644 index 00000000..b2f512ee --- /dev/null +++ b/docs/LoyaltiesMembersTransactionsExportCreateRequestBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **parameters** | [**LoyaltiesMembersTransactionsExportCreateRequestBodyParameters**](LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md b/docs/LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md new file mode 100644 index 00000000..783043d0 --- /dev/null +++ b/docs/LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBodyParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | [**ExportVoucherTransactionsOrder**](ExportVoucherTransactionsOrder.md) | | [optional] | +| **fields** | [**Array<ExportVoucherTransactionsFields>**](ExportVoucherTransactionsFields.md) | Array of strings containing the data in the export. These fields define the headers in the CSV file. | [optional] | +| **filters** | [**ExportVoucherTransactionsFilters**](ExportVoucherTransactionsFilters.md) | | [optional] | + diff --git a/docs/LoyaltiesMembersTransactionsExportCreateResponseBody.md b/docs/LoyaltiesMembersTransactionsExportCreateResponseBody.md new file mode 100644 index 00000000..1498ab4f --- /dev/null +++ b/docs/LoyaltiesMembersTransactionsExportCreateResponseBody.md @@ -0,0 +1,16 @@ +# VoucherifySdk::LoyaltiesMembersTransactionsExportCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'voucher_transactions'] | +| **parameters** | [**LoyaltiesMembersTransactionsExportCreateRequestBodyParameters**](LoyaltiesMembersTransactionsExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/LoyaltiesMembersTransactionsListResponseBody.md b/docs/LoyaltiesMembersTransactionsListResponseBody.md new file mode 100644 index 00000000..00f39b6c --- /dev/null +++ b/docs/LoyaltiesMembersTransactionsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesMembersTransactionsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of transaction objects. | [default to 'data'] | +| **data** | [**Array<LoyaltyCardTransaction>**](LoyaltyCardTransaction.md) | A dictionary that contains an array of transactions. Each entry in the array is a separate transaction object. | | +| **has_more** | **Boolean** | As query results are always limited (by the limit parameter), the has_more flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. | | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBody.md b/docs/LoyaltiesMembersTransfersCreateResponseBody.md new file mode 100644 index 00000000..0b9b9923 --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBody.md @@ -0,0 +1,30 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the voucher. | | +| **code** | **String** | A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. | | +| **campaign** | **String** | A unique campaign name, identifies the voucher's parent campaign. | [optional] | +| **campaign_id** | **String** | Assigned by the Voucherify API, identifies the voucher's parent campaign. | [optional] | +| **category** | **String** | Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. | | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | | +| **categories** | [**Array<Category>**](Category.md) | | [optional] | +| **type** | **String** | Defines the type of the voucher. | [default to 'LOYALTY_CARD'] | +| **loyalty_card** | [**LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard**](LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard.md) | | | +| **start_date** | **Time** | Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is inactive before this date. | | +| **expiration_date** | **Time** | Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is inactive after this date. | | +| **validity_timeframe** | [**LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe**](LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe.md) | | | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | | +| **publish** | [**LoyaltiesMembersTransfersCreateResponseBodyPublish**](LoyaltiesMembersTransfersCreateResponseBodyPublish.md) | | [optional] | +| **redemption** | [**LoyaltiesMembersTransfersCreateResponseBodyRedemption**](LoyaltiesMembersTransfersCreateResponseBodyRedemption.md) | | [optional] | +| **active** | **String** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the start_date and expiration_date. - `true` indicates an active voucher - `false` indicates an inactive voucher | | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | | +| **assets** | [**LoyaltiesMembersTransfersCreateResponseBodyAssets**](LoyaltiesMembersTransfersCreateResponseBodyAssets.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | | +| **holder_id** | **String** | Unique customer ID of voucher owner. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. | [optional] | +| **created_at** | **Time** | | | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBodyAssets.md b/docs/LoyaltiesMembersTransfersCreateResponseBodyAssets.md new file mode 100644 index 00000000..a33442df --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBodyAssets.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssets + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **qr** | [**LoyaltiesMembersTransfersCreateResponseBodyAssetsQr**](LoyaltiesMembersTransfersCreateResponseBodyAssetsQr.md) | | [optional] | +| **barcode** | [**LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode**](LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode.md) | | [optional] | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode.md b/docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode.md new file mode 100644 index 00000000..bf819ee7 --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Encrypted voucher code ID. | [optional] | +| **url** | **String** | URL to barcode *Optional:* Attach query parameters to base URL to customize the image of the encrypted voucher code. - `size`: integer value from `1` to `100` - `format`: string, either `png` (default) or `svg` | [optional] | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsQr.md b/docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsQr.md new file mode 100644 index 00000000..7e5c697d --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBodyAssetsQr.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsQr + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Encrypted voucher code ID. | [optional] | +| **url** | **String** | URL to QR code *Optional:* Attach query parameters to base URL to customize the image of the encrypted voucher code. - `size`: integer value from `1` to `100` - `format`: string, either `png` (default) or `svg` | [optional] | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard.md b/docs/LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard.md new file mode 100644 index 00000000..087effaf --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Total points incurred over lifespan of loyalty card. | | +| **balance** | **Integer** | Points available for reward redemption. | | +| **next_expiration_date** | **String** | The next closest date when the next set of points are due to expire. | [optional] | +| **next_expiration_points** | **Integer** | The amount of points that are set to expire next. | [optional] | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBodyPublish.md b/docs/LoyaltiesMembersTransfersCreateResponseBodyPublish.md new file mode 100644 index 00000000..3f95b2fa --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBodyPublish.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyPublish + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented is by default list. To get this list, you need to make a call to the endpoint returned in the url attribute. | [default to 'list'] | +| **count** | **Integer** | Publication events counter. | [optional] | +| **entries** | **Array<String>** | | [optional] | +| **url** | **String** | The endpoint where this list of publications can be accessed using a GET method. /v1/vouchers/{voucher_code}/publications | [optional] | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBodyRedemption.md b/docs/LoyaltiesMembersTransfersCreateResponseBodyRedemption.md new file mode 100644 index 00000000..2ce5731a --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBodyRedemption.md @@ -0,0 +1,13 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **quantity** | **Integer** | How many times a voucher can be redeemed. A null value means unlimited. | | +| **redeemed_points** | **Integer** | Total loyalty points redeemed. | [optional] | +| **redeemed_quantity** | **Integer** | How many times a voucher has already been redeemed. | [optional] | +| **redemption_entries** | **Array<String>** | | [optional] | +| **object** | **String** | The type of object represented is by default list. To get this list, you need to make a call to the endpoint returned in the url attribute. | [optional][default to 'list'] | +| **url** | **String** | The endpoint where this list of redemptions can be accessed using a GET method. /v1/vouchers/{voucher_code}/redemptions | [optional] | + diff --git a/docs/LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe.md b/docs/LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe.md new file mode 100644 index 00000000..76013cc4 --- /dev/null +++ b/docs/LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **interval** | **String** | Defines the amount of time the voucher will be active in ISO 8601 format. For example, a voucher with a duration of PT1H will be valid for a duration of one hour. | [optional] | +| **duration** | **String** | Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a voucher with an interval of P2D will be active every other day. | [optional] | + diff --git a/docs/LoyaltiesRewardAssignmentsGetResponseBody.md b/docs/LoyaltiesRewardAssignmentsGetResponseBody.md new file mode 100644 index 00000000..18780e1e --- /dev/null +++ b/docs/LoyaltiesRewardAssignmentsGetResponseBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::LoyaltiesRewardAssignmentsGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward assignment ID, assigned by Voucherify. | | +| **reward_id** | **String** | Associated reward ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward assignment. | [default to 'reward_assignment'] | +| **related_object_id** | **String** | Related object ID to which the reward was assigned. | | +| **related_object_type** | **String** | Related object type to which the reward was assigned. | [default to 'campaign'] | +| **parameters** | [**RewardAssignmentParametersParameters**](RewardAssignmentParametersParameters.md) | | [optional] | + diff --git a/docs/LoyaltiesRewardAssignmentsRewardGetResponseBody.md b/docs/LoyaltiesRewardAssignmentsRewardGetResponseBody.md new file mode 100644 index 00000000..b1bafd5d --- /dev/null +++ b/docs/LoyaltiesRewardAssignmentsRewardGetResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::LoyaltiesRewardAssignmentsRewardGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward ID, assigned by Voucherify. | | +| **name** | **String** | Reward name. | | +| **stock** | **Integer** | Configurable for **material rewards**. The number of units of the product that you want to share as reward. | | +| **redeemed** | **Integer** | Defines the number of already invoked (successful) reward redemptions. | | +| **attributes** | [**RewardAttributes**](RewardAttributes.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the reward. A set of key/value pairs that you can attach to a reward object. It can be useful for storing additional information about the reward in a structured format. | | +| **type** | **String** | Reward type. | | +| **parameters** | [**RewardType**](RewardType.md) | | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the reward was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward. | [default to 'reward'] | + diff --git a/docs/LoyaltiesRewardsGetResponseBody.md b/docs/LoyaltiesRewardsGetResponseBody.md new file mode 100644 index 00000000..a58a0633 --- /dev/null +++ b/docs/LoyaltiesRewardsGetResponseBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::LoyaltiesRewardsGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward assignment ID, assigned by Voucherify. | | +| **reward_id** | **String** | Associated reward ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward assignment. | [default to 'reward_assignment'] | +| **related_object_id** | **String** | Related object ID to which the reward was assigned. | | +| **related_object_type** | **String** | Related object type to which the reward was assigned. | [default to 'campaign'] | +| **parameters** | [**RewardAssignmentParametersParameters**](RewardAssignmentParametersParameters.md) | | [optional] | + diff --git a/docs/LoyaltiesTiersCreateInBulkRequestBodyItem.md b/docs/LoyaltiesTiersCreateInBulkRequestBodyItem.md new file mode 100644 index 00000000..0fb299d0 --- /dev/null +++ b/docs/LoyaltiesTiersCreateInBulkRequestBodyItem.md @@ -0,0 +1,12 @@ +# VoucherifySdk::LoyaltiesTiersCreateInBulkRequestBodyItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Loyalty Tier name. | | +| **earning_rules** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of earning rule IDs and their points mapping for the given earning rule. | [optional] | +| **rewards** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of reward IDs and their points mapping for the given reward. | [optional] | +| **points** | [**LoyaltyTierBasePoints**](LoyaltyTierBasePoints.md) | | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the loyalty tier. A set of key/value pairs that you can attach to a loyalty tier object. It can be useful for storing additional information about the loyalty tier in a structured format. | [optional] | + diff --git a/docs/LoyaltiesTiersEarningRulesListResponseBody.md b/docs/LoyaltiesTiersEarningRulesListResponseBody.md new file mode 100644 index 00000000..b8056f83 --- /dev/null +++ b/docs/LoyaltiesTiersEarningRulesListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesTiersEarningRulesListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about earning rules in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of earning rule objects. | [default to 'data'] | +| **data** | [**Array<EarningRule>**](EarningRule.md) | Contains array of earning rule objects. | | +| **total** | **Integer** | Total number of earning rule objects. | | + diff --git a/docs/LoyaltiesTiersGetResponseBody.md b/docs/LoyaltiesTiersGetResponseBody.md new file mode 100644 index 00000000..94dc82c6 --- /dev/null +++ b/docs/LoyaltiesTiersGetResponseBody.md @@ -0,0 +1,19 @@ +# VoucherifySdk::LoyaltiesTiersGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Loyalty Tier name. | | +| **earning_rules** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of earning rule IDs and their points mapping for the given earning rule. | [optional] | +| **rewards** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of reward IDs and their points mapping for the given reward. | [optional] | +| **points** | [**LoyaltyTierBasePoints**](LoyaltyTierBasePoints.md) | | | +| **id** | **String** | Unique loyalty tier ID. | | +| **campaign_id** | **String** | Unique parent campaign ID. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the loyalty tier. A set of key/value pairs that you can attach to a loyalty tier object. It can be useful for storing additional information about the loyalty tier in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the loyalty tier was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the loyalty tier was updated in ISO 8601 format. | [optional] | +| **config** | [**LoyaltyTierAllOfConfig**](LoyaltyTierAllOfConfig.md) | | | +| **expiration** | [**LoyaltyTierExpiration**](LoyaltyTierExpiration.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the loyalty. | [default to 'loyalty_tier'] | + diff --git a/docs/LoyaltiesTiersListResponseBody.md b/docs/LoyaltiesTiersListResponseBody.md new file mode 100644 index 00000000..7e9bc237 --- /dev/null +++ b/docs/LoyaltiesTiersListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesTiersListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about loyalty tiers in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of loyalty tier objects. | [default to 'data'] | +| **data** | [**Array<LoyaltyTier>**](LoyaltyTier.md) | This is an object representing a loyalty tier. Loyalty tiers are used to create a loyalty program with different levels of membership and varied earning rules and rewards based on customer’s tiers. | | +| **total** | **Integer** | Total number of loyalty tier objects. | | + diff --git a/docs/LoyaltiesTiersRewardsListResponseBody.md b/docs/LoyaltiesTiersRewardsListResponseBody.md new file mode 100644 index 00000000..73533312 --- /dev/null +++ b/docs/LoyaltiesTiersRewardsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesTiersRewardsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about loyalty tier rewards in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of loyalty tier reward objects. | [default to 'data'] | +| **data** | [**Array<LoyaltiesLoyaltyTierReward>**](LoyaltiesLoyaltyTierReward.md) | Contains array of loyalty tier reward objects. | | +| **total** | **Integer** | Total number of loyalty tier reward objects. | | + diff --git a/docs/LoyaltiesTransferPoints.md b/docs/LoyaltiesTransferPoints.md new file mode 100644 index 00000000..1562fe74 --- /dev/null +++ b/docs/LoyaltiesTransferPoints.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltiesTransferPoints + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | Unique loyalty card code from which the user wants to transfer loyalty points (source). | | +| **points** | **Integer** | The number of loyalty points that the user wants to transfer to another loyalty card. The number of points cannot be higher than the current balance on the loyalty card (source). | | +| **reason** | **String** | Reason for the transfer. | [optional] | +| **source_id** | **String** | The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. | | + diff --git a/docs/LoyaltyCardTransaction.md b/docs/LoyaltyCardTransaction.md new file mode 100644 index 00000000..dc8dcab8 --- /dev/null +++ b/docs/LoyaltyCardTransaction.md @@ -0,0 +1,17 @@ +# VoucherifySdk::LoyaltyCardTransaction + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique transaction ID. | | +| **source_id** | **String** | The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. In case of a redemption, this value is null. | | +| **voucher_id** | **String** | Unique voucher ID. | | +| **campaign_id** | **String** | Unqiue campaign ID of the voucher's parent campaign if it is part of campaign that generates bulk codes. | | +| **source** | **String** | The channel through which the transaction took place, whether through the API or the the Dashboard. In case of a redemption, this value is null. | | +| **reason** | **String** | Reason why the transaction occurred. In case of a redemption, this value is null. | | +| **type** | [**LoyaltyCardTransactionsType**](LoyaltyCardTransactionsType.md) | | | +| **details** | [**VoucherTransactionDetails**](VoucherTransactionDetails.md) | | | +| **related_transaction_id** | **String** | The related transaction ID on the receiving card. | | +| **created_at** | **Time** | Timestamp representing the date and time when the transaction was created in ISO 8601 format. | | + diff --git a/docs/LoyaltyCardTransactionsType.md b/docs/LoyaltyCardTransactionsType.md new file mode 100644 index 00000000..54ea3d26 --- /dev/null +++ b/docs/LoyaltyCardTransactionsType.md @@ -0,0 +1,7 @@ +# VoucherifySdk::LoyaltyCardTransactionsType + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/LoyaltyTier.md b/docs/LoyaltyTier.md new file mode 100644 index 00000000..b10af6ec --- /dev/null +++ b/docs/LoyaltyTier.md @@ -0,0 +1,19 @@ +# VoucherifySdk::LoyaltyTier + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Loyalty Tier name. | | +| **earning_rules** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of earning rule IDs and their points mapping for the given earning rule. | [optional] | +| **rewards** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of reward IDs and their points mapping for the given reward. | [optional] | +| **points** | [**LoyaltyTierBasePoints**](LoyaltyTierBasePoints.md) | | | +| **id** | **String** | Unique loyalty tier ID. | | +| **campaign_id** | **String** | Unique parent campaign ID. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the loyalty tier. A set of key/value pairs that you can attach to a loyalty tier object. It can be useful for storing additional information about the loyalty tier in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the loyalty tier was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the loyalty tier was updated in ISO 8601 format. | [optional] | +| **config** | [**LoyaltyTierAllOfConfig**](LoyaltyTierAllOfConfig.md) | | | +| **expiration** | [**LoyaltyTierExpiration**](LoyaltyTierExpiration.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the loyalty. | [default to 'loyalty_tier'] | + diff --git a/docs/LoyaltyTierAllOfConfig.md b/docs/LoyaltyTierAllOfConfig.md new file mode 100644 index 00000000..9bdea992 --- /dev/null +++ b/docs/LoyaltyTierAllOfConfig.md @@ -0,0 +1,8 @@ +# VoucherifySdk::LoyaltyTierAllOfConfig + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | [**LoyaltyTierAllOfConfigPoints**](LoyaltyTierAllOfConfigPoints.md) | | | + diff --git a/docs/LoyaltyTierAllOfConfigPoints.md b/docs/LoyaltyTierAllOfConfigPoints.md new file mode 100644 index 00000000..1848a12b --- /dev/null +++ b/docs/LoyaltyTierAllOfConfigPoints.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltyTierAllOfConfigPoints + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **Integer** | Bottom points threshold value. | [optional] | +| **to** | **Integer** | Top points threshold value. | [optional] | + diff --git a/docs/LoyaltyTierBase.md b/docs/LoyaltyTierBase.md new file mode 100644 index 00000000..3420eaee --- /dev/null +++ b/docs/LoyaltyTierBase.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltyTierBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Loyalty Tier name. | | +| **earning_rules** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of earning rule IDs and their points mapping for the given earning rule. | [optional] | +| **rewards** | [**Hash<String, MappingPoints>**](MappingPoints.md) | Contains a list of reward IDs and their points mapping for the given reward. | [optional] | +| **points** | [**LoyaltyTierBasePoints**](LoyaltyTierBasePoints.md) | | | + diff --git a/docs/LoyaltyTierBasePoints.md b/docs/LoyaltyTierBasePoints.md new file mode 100644 index 00000000..5d4e8c7a --- /dev/null +++ b/docs/LoyaltyTierBasePoints.md @@ -0,0 +1,9 @@ +# VoucherifySdk::LoyaltyTierBasePoints + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **from** | **Integer** | Bottom points threshold value. | [optional] | +| **to** | **Integer** | Top points threshold value. | [optional] | + diff --git a/docs/LoyaltyTierExpiration.md b/docs/LoyaltyTierExpiration.md new file mode 100644 index 00000000..7e63f5f6 --- /dev/null +++ b/docs/LoyaltyTierExpiration.md @@ -0,0 +1,14 @@ +# VoucherifySdk::LoyaltyTierExpiration + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | | +| **campaign_id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **tier_id** | **String** | Unique tier ID, assigned by Voucherify. | | +| **start_date** | **String** | Activation timestamp defines when the loyalty tier starts to be active in ISO 8601 format. Loyalty tier is inactive before this date. | [optional] | +| **expiration_date** | **String** | Expiration timestamp defines when the loyalty tier expires in ISO 8601 format. Loyalty tier is inactive after this date. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the loyalty tier was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the loyalty tier was updated in ISO 8601 format. | [optional] | + diff --git a/docs/LoyaltyTiersExpirationAll.md b/docs/LoyaltyTiersExpirationAll.md new file mode 100644 index 00000000..2a1c0d0d --- /dev/null +++ b/docs/LoyaltyTiersExpirationAll.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltyTiersExpirationAll + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **qualification_type** | **String** | Tier qualification. `BALANCE`: Points balance is based on the customer's current points balance. Customers qualify for the tier if their points balance is in the points range of the tier. `POINTS_IN_PERIOD`: A customer qualifies for the tier only if the sum of the accumulated points in a **defined time interval** reaches the tier threshold. | | +| **qualification_period** | **String** | Customers can qualify for the tier if they collected enough points in a given time period. So, in addition to the customer having to reach a points range, they also need to have collected the points within a set time period. | **Period** | **Definition** | |:---|:---| | **Calendar Month** | Points collected in one calendar month<br>January, February, March, etc. | | **Calendar Quarter** | Points collected in the quarter<br>- January - March<br>- April - June<br>- July - September<br>- October - December | | **Calendar Half-year** | Points collected in the half-year<br>- January - June<br>- July - December | | **Calendar Year** | Points collected in one calendar year<br>January - December | | [optional] | +| **start_date** | [**LoyaltyTiersExpirationAllStartDate**](LoyaltyTiersExpirationAllStartDate.md) | | | +| **expiration_date** | [**LoyaltyTiersExpirationAllExpirationDate**](LoyaltyTiersExpirationAllExpirationDate.md) | | | + diff --git a/docs/LoyaltyTiersExpirationAllExpirationDate.md b/docs/LoyaltyTiersExpirationAllExpirationDate.md new file mode 100644 index 00000000..8194f87a --- /dev/null +++ b/docs/LoyaltyTiersExpirationAllExpirationDate.md @@ -0,0 +1,10 @@ +# VoucherifySdk::LoyaltyTiersExpirationAllExpirationDate + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | What triggers the tier to expire for a customer. `END_OF_PERIOD`: Expire tier at the end of the period. `END_OF_NEXT_PERIOD`: Expire tier at the end of the next period. `BALANCE_DROP`: Tier expires when the points balance drops below the required range of the tier. `CUSTOM`: Tier expires after a certain time period passes following the instance the points balance drops below the required range of the tier. | | +| **extend** | **String** | Extend the expiration by adding extra months or days in ISO 8601 format. The tier will remain active even though it reaches its expiration time period. For example, a tier with a duration of `P3M` will be valid for an additional duration of 3 months and a tier with a duration of `P1D` will be valid for an additional duration of 1 day. | | +| **rounding** | [**LoyaltyTiersExpirationAllExpirationDateRounding**](LoyaltyTiersExpirationAllExpirationDateRounding.md) | | [optional] | + diff --git a/docs/LoyaltyTiersExpirationAllExpirationDateRounding.md b/docs/LoyaltyTiersExpirationAllExpirationDateRounding.md new file mode 100644 index 00000000..533280a2 --- /dev/null +++ b/docs/LoyaltyTiersExpirationAllExpirationDateRounding.md @@ -0,0 +1,11 @@ +# VoucherifySdk::LoyaltyTiersExpirationAllExpirationDateRounding + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | This mechanism describes a custom rounding for the expiration date. | [optional] | +| **strategy** | **String** | This mechanism describes a rounding strategy for the expiration date. | [optional] | +| **unit** | **String** | Defines the type of unit of time in which the rounding period is counted. | [optional][default to 'MONTH'] | +| **value** | **Integer** | Value for the unit of time that the rounding applies to. Units for this parameter are defined by the `rounding.unit` parameter. - `0`: January - `1`: February - `2`: March - `3`: April - `4`: May - `5`: June - `6`: July - `7`: August - `8`: September - `9`: October - `10`: November - `11`: December | [optional] | + diff --git a/docs/LoyaltyTiersExpirationAllStartDate.md b/docs/LoyaltyTiersExpirationAllStartDate.md new file mode 100644 index 00000000..54758b0b --- /dev/null +++ b/docs/LoyaltyTiersExpirationAllStartDate.md @@ -0,0 +1,8 @@ +# VoucherifySdk::LoyaltyTiersExpirationAllStartDate + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | What triggers the tier to be valid for a customer. `IMMEDIATE`: After reaching the minimum required points. `NEXT_PERIOD`: When the next qualification period starts. | | + diff --git a/docs/LuckyDraw.md b/docs/LuckyDraw.md new file mode 100644 index 00000000..589f11bc --- /dev/null +++ b/docs/LuckyDraw.md @@ -0,0 +1,10 @@ +# VoucherifySdk::LuckyDraw + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **winners_count** | **String** | It represents the total number of winners in a lucky draw. | [optional] | +| **unique_winners_per_draw** | **String** | It indicates whether each winner in a draw is unique or not. | [optional] | +| **unique_winners** | **String** | Specifies whether each participant can win only once across multiple draws. | [optional] | + diff --git a/docs/MappingFixed.md b/docs/MappingFixed.md new file mode 100644 index 00000000..8414ebf9 --- /dev/null +++ b/docs/MappingFixed.md @@ -0,0 +1,9 @@ +# VoucherifySdk::MappingFixed + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of calculation. | [optional][default to 'CUSTOM'] | +| **points** | **Integer** | Fixed number of points to be applied. | [optional] | + diff --git a/docs/MappingMultiply.md b/docs/MappingMultiply.md new file mode 100644 index 00000000..0522c401 --- /dev/null +++ b/docs/MappingMultiply.md @@ -0,0 +1,9 @@ +# VoucherifySdk::MappingMultiply + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of calculation. | [optional][default to 'MULTIPLY'] | +| **multiplier** | **Float** | Multiplication factor used to multiply the points to obtain the mapped points. | [optional] | + diff --git a/docs/MappingPoints.md b/docs/MappingPoints.md new file mode 100644 index 00000000..7643e432 --- /dev/null +++ b/docs/MappingPoints.md @@ -0,0 +1,49 @@ +# VoucherifySdk::MappingPoints + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::MappingPoints.openapi_one_of +# => +# [ +# :'MappingFixed', +# :'MappingMultiply' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::MappingPoints.build(data) +# => # + +VoucherifySdk::MappingPoints.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `MappingFixed` +- `MappingMultiply` +- `nil` (if no type matches) + diff --git a/docs/Order.md b/docs/Order.md new file mode 100644 index 00000000..ca6015e3 --- /dev/null +++ b/docs/Order.md @@ -0,0 +1,19 @@ +# VoucherifySdk::Order + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **items** | [**Array<OrderItem>**](OrderItem.md) | Array of items applied to the order. | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | [optional] | +| **referrer** | [**Referrer**](Referrer.md) | | [optional] | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | [optional] | + diff --git a/docs/OrderBase.md b/docs/OrderBase.md new file mode 100644 index 00000000..2a4a3491 --- /dev/null +++ b/docs/OrderBase.md @@ -0,0 +1,17 @@ +# VoucherifySdk::OrderBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **items** | [**Array<OrderItem>**](OrderItem.md) | Array of items applied to the order. | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | [optional] | +| **referrer** | [**Referrer**](Referrer.md) | | [optional] | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | + diff --git a/docs/OrderCalculated.md b/docs/OrderCalculated.md new file mode 100644 index 00000000..52eb5c35 --- /dev/null +++ b/docs/OrderCalculated.md @@ -0,0 +1,29 @@ +# VoucherifySdk::OrderCalculated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | | +| **created_at** | **Time** | Timestamp representing the date and time when the order was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the order was last updated in ISO 8601 format. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **items_discount_amount** | **Integer** | Sum of all product-specific discounts applied to the order. | [optional] | +| **total_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied to the order. | [optional] | +| **total_amount** | **Integer** | Order amount after undoing all the discounts through the rollback redemption. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **items_applied_discount_amount** | **Integer** | Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **items** | [**Array<OrderItemCalculated>**](OrderItemCalculated.md) | Array of items applied to the order. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | | +| **referrer_id** | **String** | Unique referrer ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'order'] | +| **redemptions** | [**Hash<String, OrderRedemptions>**](OrderRedemptions.md) | | [optional] | +| **customer** | [**OrderCalculatedCustomer**](OrderCalculatedCustomer.md) | | [optional] | +| **referrer** | [**OrderCalculatedReferrer**](OrderCalculatedReferrer.md) | | [optional] | + diff --git a/docs/OrderCalculatedBase.md b/docs/OrderCalculatedBase.md new file mode 100644 index 00000000..f854c271 --- /dev/null +++ b/docs/OrderCalculatedBase.md @@ -0,0 +1,27 @@ +# VoucherifySdk::OrderCalculatedBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | | +| **created_at** | **Time** | Timestamp representing the date and time when the order was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the order was last updated in ISO 8601 format. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **items_discount_amount** | **Integer** | Sum of all product-specific discounts applied to the order. | [optional] | +| **total_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied to the order. | [optional] | +| **total_amount** | **Integer** | Order amount after undoing all the discounts through the rollback redemption. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **items_applied_discount_amount** | **Integer** | Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **items** | [**Array<OrderItemCalculated>**](OrderItemCalculated.md) | Array of items applied to the order. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | | +| **referrer_id** | **String** | Unique referrer ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'order'] | +| **redemptions** | [**Hash<String, OrderRedemptions>**](OrderRedemptions.md) | | [optional] | + diff --git a/docs/OrderCalculatedCustomer.md b/docs/OrderCalculatedCustomer.md new file mode 100644 index 00000000..246db826 --- /dev/null +++ b/docs/OrderCalculatedCustomer.md @@ -0,0 +1,49 @@ +# VoucherifySdk::OrderCalculatedCustomer + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::OrderCalculatedCustomer.openapi_one_of +# => +# [ +# :'CustomerId', +# :'CustomerWithSummaryLoyaltyReferrals' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::OrderCalculatedCustomer.build(data) +# => # + +VoucherifySdk::OrderCalculatedCustomer.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `CustomerId` +- `CustomerWithSummaryLoyaltyReferrals` +- `nil` (if no type matches) + diff --git a/docs/OrderCalculatedNoCustomerData.md b/docs/OrderCalculatedNoCustomerData.md new file mode 100644 index 00000000..d5f1af7c --- /dev/null +++ b/docs/OrderCalculatedNoCustomerData.md @@ -0,0 +1,29 @@ +# VoucherifySdk::OrderCalculatedNoCustomerData + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | | +| **created_at** | **Time** | Timestamp representing the date and time when the order was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the order was last updated in ISO 8601 format. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **items_discount_amount** | **Integer** | Sum of all product-specific discounts applied to the order. | [optional] | +| **total_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied to the order. | [optional] | +| **total_amount** | **Integer** | Order amount after undoing all the discounts through the rollback redemption. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **items_applied_discount_amount** | **Integer** | Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **items** | [**Array<OrderItemCalculated>**](OrderItemCalculated.md) | Array of items applied to the order. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | | +| **referrer_id** | **String** | Unique referrer ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'order'] | +| **redemptions** | [**Hash<String, OrderRedemptions>**](OrderRedemptions.md) | | [optional] | +| **customer** | [**CustomerId**](CustomerId.md) | | [optional] | +| **referrer** | [**ReferrerId**](ReferrerId.md) | | [optional] | + diff --git a/docs/OrderCalculatedReferrer.md b/docs/OrderCalculatedReferrer.md new file mode 100644 index 00000000..e1b1095c --- /dev/null +++ b/docs/OrderCalculatedReferrer.md @@ -0,0 +1,49 @@ +# VoucherifySdk::OrderCalculatedReferrer + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::OrderCalculatedReferrer.openapi_one_of +# => +# [ +# :'ReferrerId', +# :'ReferrerWithSummaryLoyaltyReferrals' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::OrderCalculatedReferrer.build(data) +# => # + +VoucherifySdk::OrderCalculatedReferrer.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ReferrerId` +- `ReferrerWithSummaryLoyaltyReferrals` +- `nil` (if no type matches) + diff --git a/docs/OrderItem.md b/docs/OrderItem.md new file mode 100644 index 00000000..afecf1c1 --- /dev/null +++ b/docs/OrderItem.md @@ -0,0 +1,21 @@ +# VoucherifySdk::OrderItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **sku_id** | **String** | A unique SKU ID assigned by Voucherify. | [optional] | +| **product_id** | **String** | A unique product ID assigned by Voucherify. | [optional] | +| **related_object** | **String** | Used along with the source_id property, can be set to either sku or product. | [optional] | +| **source_id** | **String** | The merchant’s product/SKU ID (if it is different from the Voucherify product/SKU ID). It is useful in the integration between multiple systems. It can be an ID from an eCommerce site, a database, or a third-party service. | [optional] | +| **quantity** | **Integer** | The quantity of the particular item in the cart. | [optional] | +| **discount_quantity** | **Integer** | Number of dicounted items. | [optional] | +| **initial_quantity** | **Integer** | A positive integer in the smallest unit quantity representing the total amount of the order; this is the sum of the order items' quantity. | [optional] | +| **amount** | **Integer** | The total amount of the order item (price * quantity). | [optional] | +| **discount_amount** | **Integer** | Sum of all order-item-level discounts applied to the order. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **price** | **Integer** | Unit price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [optional] | +| **product** | [**OrderItemProduct**](OrderItemProduct.md) | | [optional] | +| **sku** | [**OrderItemSku**](OrderItemSku.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an SKU. It can be useful for storing additional information about the SKU in a structured format. | [optional] | + diff --git a/docs/OrderItemCalculated.md b/docs/OrderItemCalculated.md new file mode 100644 index 00000000..2a5e5852 --- /dev/null +++ b/docs/OrderItemCalculated.md @@ -0,0 +1,25 @@ +# VoucherifySdk::OrderItemCalculated + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **sku_id** | **String** | A unique SKU ID assigned by Voucherify. | [optional] | +| **product_id** | **String** | A unique product ID assigned by Voucherify. | [optional] | +| **related_object** | **String** | Used along with the source_id property, can be set to either sku or product. | [optional] | +| **source_id** | **String** | The merchant’s product/SKU ID (if it is different from the Voucherify product/SKU ID). It is useful in the integration between multiple systems. It can be an ID from an eCommerce site, a database, or a third-party service. | [optional] | +| **quantity** | **Integer** | The quantity of the particular item in the cart. | [optional] | +| **discount_quantity** | **Integer** | Number of dicounted items. | [optional] | +| **initial_quantity** | **Integer** | A positive integer in the smallest unit quantity representing the total amount of the order; this is the sum of the order items' quantity. | [optional] | +| **amount** | **Integer** | The total amount of the order item (price * quantity). | [optional] | +| **discount_amount** | **Integer** | Sum of all order-item-level discounts applied to the order. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **price** | **Integer** | Unit price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [optional] | +| **subtotal_amount** | **Integer** | Final order item amount after the applied item-level discount. If there are no item-level discounts applied, this item is equal to the `amount`. `subtotal_amount`=`amount`-`applied_discount_amount` | [optional] | +| **product** | [**OrderItemProduct**](OrderItemProduct.md) | | [optional] | +| **sku** | [**OrderItemSku**](OrderItemSku.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'order_item'] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an SKU. It can be useful for storing additional information about the SKU in a structured format. | [optional] | + diff --git a/docs/OrderItemProduct.md b/docs/OrderItemProduct.md new file mode 100644 index 00000000..0fb40bf6 --- /dev/null +++ b/docs/OrderItemProduct.md @@ -0,0 +1,13 @@ +# VoucherifySdk::OrderItemProduct + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the product and is assigned by Voucherify. | [optional] | +| **source_id** | **String** | The merchant’s product ID (if it is different than Voucherify's product ID). It is really useful in case of integration between multiple systems. It can be an ID from an eCommerce site, a database or a 3rd party service. | [optional] | +| **override** | **Boolean** | The override set to `true` is used to store the product information in the system. If the product does not exist, it will be created with a source_id; if it does exist, the provided values for the name, price, and metadata will replace those already stored in the system. | [optional] | +| **name** | **String** | Product name. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a product. It can be useful for storing additional information about the product in a structured format. | [optional] | +| **price** | **Float** | Product price. A positive integer in the smallest currency unit (e.g. 100 cents for $1.00). | [optional] | + diff --git a/docs/OrderItemSku.md b/docs/OrderItemSku.md new file mode 100644 index 00000000..e0052426 --- /dev/null +++ b/docs/OrderItemSku.md @@ -0,0 +1,12 @@ +# VoucherifySdk::OrderItemSku + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the SKU and is assigned by Voucherify. | [optional] | +| **source_id** | **String** | The merchant’s SKU ID (if it is different than Voucherify's SKU ID). It is really useful in case of integration between multiple systems. It can be an ID from an eCommerce site, a database or a 3rd party service. | [optional] | +| **override** | **Boolean** | The override set to `true` is used to store the product information in the system. If the product does not exist, it will be created with a source_id; if it does exist, the provided values for the name, price, and metadata will replace those already stored in the system. | [optional] | +| **sku** | **String** | The SKU name. | [optional] | +| **price** | **Float** | SKU price. A positive integer in the smallest currency unit (e.g. 100 cents for $1.00). | [optional] | + diff --git a/docs/OrderRedemptions.md b/docs/OrderRedemptions.md new file mode 100644 index 00000000..b49da7f2 --- /dev/null +++ b/docs/OrderRedemptions.md @@ -0,0 +1,15 @@ +# VoucherifySdk::OrderRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **date** | **Time** | Timestamp representing the date and time when the redemption was created in ISO 8601 format. | [optional] | +| **rollback_id** | **String** | Unique ID of the redemption rollback. | [optional] | +| **rollback_date** | **Time** | Timestamp representing the date and tiem when the redemption rollback was created in ISO 8601 format. | [optional] | +| **related_object_type** | **String** | The source of the incentive. | [optional][default to 'redemption'] | +| **related_object_id** | **String** | Unique ID of the parent redemption. | [optional] | +| **related_object_parent_id** | **String** | Represent's the campaign ID of the voucher if the redemption was based on a voucher that was part of bulk codes generated within a campaign. In case of a promotion tier, this represents the campaign ID of the promotion tier's parent campaign. | [optional] | +| **stacked** | **Array<String>** | Contains a list of unique IDs of child redemptions, which belong to the stacked incentives. | [optional] | +| **rollback_stacked** | **Array<String>** | Lists the rollback redemption IDs of the particular child redemptions. | [optional] | + diff --git a/docs/OrdersApi.md b/docs/OrdersApi.md new file mode 100644 index 00000000..f1f8d46f --- /dev/null +++ b/docs/OrdersApi.md @@ -0,0 +1,377 @@ +# VoucherifySdk::OrdersApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_order**](OrdersApi.md#create_order) | **POST** /v1/orders | Create Order | +| [**create_order_export**](OrdersApi.md#create_order_export) | **POST** /v1/orders/export | Create Orders Export | +| [**get_order**](OrdersApi.md#get_order) | **GET** /v1/orders/{orderId} | Get Order | +| [**import_orders**](OrdersApi.md#import_orders) | **POST** /v1/orders/import | Import Orders | +| [**list_orders**](OrdersApi.md#list_orders) | **GET** /v1/orders | List Orders | +| [**update_order**](OrdersApi.md#update_order) | **PUT** /v1/orders/{orderId} | Update Order | + + +## create_order + +> create_order(opts) + +Create Order + +Creates an order object and triggers an order creation event. 📘 Upsert Mode If you pass an id or a source_id that already exists in the order database, Voucherify will return a related order object with updated fields. + +### 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::OrdersApi.new +opts = { + orders_create_request_body: VoucherifySdk::OrdersCreateRequestBody.new # OrdersCreateRequestBody | Specify the order parameters. +} + +begin + # Create Order + result = api_instance.create_order(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling OrdersApi->create_order: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **orders_create_request_body** | [**OrdersCreateRequestBody**](OrdersCreateRequestBody.md) | Specify the order parameters. | [optional] | + +### Return type + +[**OrdersCreateResponseBody**](OrdersCreateResponseBody.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_order_export + +> create_order_export(opts) + +Create Orders Export + +Creates a downloadable CSV file containing a list of orders. The parameters listed in the payload resembles headers in the CSV file. To include a parameter to the file, add it to the parameters.fields object in the request body. The available filters are all order object attributes. Additionally, any metadata defined in the metadata schema can be exported. Passing an empty JSON will generate a file containing three default fields: id, source_id, and status. The fields array is an array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields: + +### 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::OrdersApi.new +opts = { + orders_export_create_request_body: VoucherifySdk::OrdersExportCreateRequestBody.new # OrdersExportCreateRequestBody | Specify which order parameters you would like to export. +} + +begin + # Create Orders Export + result = api_instance.create_order_export(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling OrdersApi->create_order_export: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **orders_export_create_request_body** | [**OrdersExportCreateRequestBody**](OrdersExportCreateRequestBody.md) | Specify which order parameters you would like to export. | [optional] | + +### Return type + +[**OrdersExportCreateResponseBody**](OrdersExportCreateResponseBody.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 + + +## get_order + +> get_order(order_id) + +Get Order + +Retrieve an order. + +### 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::OrdersApi.new +order_id = 'order_id_example' # String | Unique Voucherify order ID or order source ID. + +begin + # Get Order + result = api_instance.get_order(order_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling OrdersApi->get_order: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order_id** | **String** | Unique Voucherify order ID or order source ID. | | + +### Return type + +[**OrdersGetResponseBody**](OrdersGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## import_orders + +> import_orders(opts) + +Import Orders + + 🚧 Historical orders This endpoint should only be used to import historical orders into Voucherify. For on-going synchronization, the create order and update order endpoints should be used. This is critical because this endpoint does not store events or launch distributions. # Limitations ## Import volume There can be only a single on-going order import per tenant per project at a given time. The user can schedule more imports but those extra imports will be scheduled to run in sequence one by one. ## Maximum count of orders in single import There is a 2000 limit but we might decide to change it to a lower / higher value at any given time depending if we find this value is too high or too low with time. # Notifications There are no notifications on the Dashboard because this import is launched via the API. # Triggered actions If you import orders with customers, then a logic will be scheduled responsible for placing these customers into segments and refreshing the segments summary. Consequently, this update will trigger - **customers entering into segments** - **distributions** based on any rules tied to customer entering segment(s) - **earning rules** based on the customer entering segment(s) # What is not triggered 1. No webhooks are triggered during the import of orders - for both orders and upserted products / skus. 2. Distributions based on Order Update, Order Paid, Order Created and Order Cancelled. In other words if you have a distribution based on Order Paid and you import an order with a PAID status, the distribution is not going to be triggered. 3. No events are created during the import of orders - for both orders and upserted products / skus. In other words you wont see any events in the Activity tab in the Dashboard such as Order created or Order paid. If you are additionally upserting products / skus, then you wont see the Product created events listed, etc. 4. Earning rules based on Order Paid wont be triggered. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::OrdersApi.new +opts = { + orders_import_create_request_body_item: [VoucherifySdk::OrdersImportCreateRequestBodyItem.new] # Array | The request body is sent in the form of an array of order objects. +} + +begin + # Import Orders + result = api_instance.import_orders(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling OrdersApi->import_orders: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **orders_import_create_request_body_item** | [**Array<OrdersImportCreateRequestBodyItem>**](OrdersImportCreateRequestBodyItem.md) | The request body is sent in the form of an array of order objects. | [optional] | + +### Return type + +[**OrdersImportCreateResponseBody**](OrdersImportCreateResponseBody.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 + + +## list_orders + +> list_orders(opts) + +List Orders + +Returns a list of orders. + +### 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::OrdersApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrderListOrders::CREATED_AT # ParameterOrderListOrders | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. +} + +begin + # List Orders + result = api_instance.list_orders(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling OrdersApi->list_orders: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrderListOrders**](.md) | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | + +### Return type + +[**OrdersListResponseBody**](OrdersListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_order + +> update_order(order_id, opts) + +Update Order + +Updates the specified order by setting the values of the parameters passed in the request body. Any parameters not provided will be left unchanged. + +### 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::OrdersApi.new +order_id = 'order_id_example' # String | Unique Voucherify order ID or order source ID. +opts = { + orders_update_request_body: VoucherifySdk::OrdersUpdateRequestBody.new # OrdersUpdateRequestBody | Specify the parameters of the order that are to be updated. +} + +begin + # Update Order + result = api_instance.update_order(order_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling OrdersApi->update_order: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order_id** | **String** | Unique Voucherify order ID or order source ID. | | +| **orders_update_request_body** | [**OrdersUpdateRequestBody**](OrdersUpdateRequestBody.md) | Specify the parameters of the order that are to be updated. | [optional] | + +### Return type + +[**OrdersUpdateResponseBody**](OrdersUpdateResponseBody.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 + diff --git a/docs/OrdersCreateRequestBody.md b/docs/OrdersCreateRequestBody.md new file mode 100644 index 00000000..cd9a4906 --- /dev/null +++ b/docs/OrdersCreateRequestBody.md @@ -0,0 +1,19 @@ +# VoucherifySdk::OrdersCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **items** | [**Array<OrderItem>**](OrderItem.md) | Array of items applied to the order. | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | [optional] | +| **referrer** | [**Referrer**](Referrer.md) | | [optional] | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | + diff --git a/docs/OrdersCreateResponseBody.md b/docs/OrdersCreateResponseBody.md new file mode 100644 index 00000000..bed08297 --- /dev/null +++ b/docs/OrdersCreateResponseBody.md @@ -0,0 +1,29 @@ +# VoucherifySdk::OrdersCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | | +| **created_at** | **Time** | Timestamp representing the date and time when the order was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the order was last updated in ISO 8601 format. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **items_discount_amount** | **Integer** | Sum of all product-specific discounts applied to the order. | [optional] | +| **total_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied to the order. | [optional] | +| **total_amount** | **Integer** | Order amount after undoing all the discounts through the rollback redemption. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **items_applied_discount_amount** | **Integer** | Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **items** | [**Array<OrderItemCalculated>**](OrderItemCalculated.md) | Array of items applied to the order. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | | +| **referrer_id** | **String** | Unique referrer ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'order'] | +| **redemptions** | [**Hash<String, OrderRedemptions>**](OrderRedemptions.md) | | [optional] | +| **customer** | [**OrderCalculatedCustomer**](OrderCalculatedCustomer.md) | | [optional] | +| **referrer** | [**OrderCalculatedReferrer**](OrderCalculatedReferrer.md) | | [optional] | + diff --git a/docs/OrdersExportCreateRequestBody.md b/docs/OrdersExportCreateRequestBody.md new file mode 100644 index 00000000..61b9a337 --- /dev/null +++ b/docs/OrdersExportCreateRequestBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::OrdersExportCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **parameters** | [**OrdersExportCreateRequestBodyParameters**](OrdersExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/OrdersExportCreateRequestBodyParameters.md b/docs/OrdersExportCreateRequestBodyParameters.md new file mode 100644 index 00000000..d9bf6133 --- /dev/null +++ b/docs/OrdersExportCreateRequestBodyParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::OrdersExportCreateRequestBodyParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | [**ExportOrderOrder**](ExportOrderOrder.md) | | [optional] | +| **fields** | [**Array<ExportOrderFields>**](ExportOrderFields.md) | Array of strings containing the data in the export. These fields define the headers in the CSV file. | [optional] | +| **filters** | **Object** | Allowed additional properties must start with \"metadata.\" | [optional] | + diff --git a/docs/OrdersExportCreateResponseBody.md b/docs/OrdersExportCreateResponseBody.md new file mode 100644 index 00000000..7770238a --- /dev/null +++ b/docs/OrdersExportCreateResponseBody.md @@ -0,0 +1,16 @@ +# VoucherifySdk::OrdersExportCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the export. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [optional] | +| **result** | **Object** | Contains the URL of the CSV file. | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. | | +| **exported_object** | **String** | The type of object to be exported. | [default to 'order'] | +| **parameters** | [**OrdersExportCreateRequestBodyParameters**](OrdersExportCreateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/OrdersGetResponseBody.md b/docs/OrdersGetResponseBody.md new file mode 100644 index 00000000..fd3d1788 --- /dev/null +++ b/docs/OrdersGetResponseBody.md @@ -0,0 +1,29 @@ +# VoucherifySdk::OrdersGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | | +| **created_at** | **Time** | Timestamp representing the date and time when the order was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the order was last updated in ISO 8601 format. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **items_discount_amount** | **Integer** | Sum of all product-specific discounts applied to the order. | [optional] | +| **total_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied to the order. | [optional] | +| **total_amount** | **Integer** | Order amount after undoing all the discounts through the rollback redemption. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **items_applied_discount_amount** | **Integer** | Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **items** | [**Array<OrderItemCalculated>**](OrderItemCalculated.md) | Array of items applied to the order. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | | +| **referrer_id** | **String** | Unique referrer ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'order'] | +| **redemptions** | [**Hash<String, OrderRedemptions>**](OrderRedemptions.md) | | [optional] | +| **customer** | [**CustomerId**](CustomerId.md) | | [optional] | +| **referrer** | [**ReferrerId**](ReferrerId.md) | | [optional] | + diff --git a/docs/OrdersImportCreateRequestBodyItem.md b/docs/OrdersImportCreateRequestBodyItem.md new file mode 100644 index 00000000..7d1bcb4f --- /dev/null +++ b/docs/OrdersImportCreateRequestBodyItem.md @@ -0,0 +1,18 @@ +# VoucherifySdk::OrdersImportCreateRequestBodyItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **items** | [**Array<OrderItem>**](OrderItem.md) | Array of items applied to the order. | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | [optional] | +| **referrer** | [**Referrer**](Referrer.md) | | [optional] | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | [optional] | + diff --git a/docs/OrdersImportCreateResponseBody.md b/docs/OrdersImportCreateResponseBody.md new file mode 100644 index 00000000..6bc775a3 --- /dev/null +++ b/docs/OrdersImportCreateResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::OrdersImportCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/OrdersListResponseBody.md b/docs/OrdersListResponseBody.md new file mode 100644 index 00000000..37a32af9 --- /dev/null +++ b/docs/OrdersListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::OrdersListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about orders in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of order objects. | [default to 'orders'] | +| **orders** | [**Array<OrderCalculatedNoCustomerData>**](OrderCalculatedNoCustomerData.md) | Contains array of order objects. | | +| **total** | **Integer** | Total number of orders. | | + diff --git a/docs/OrdersUpdateRequestBody.md b/docs/OrdersUpdateRequestBody.md new file mode 100644 index 00000000..b2c1c1f5 --- /dev/null +++ b/docs/OrdersUpdateRequestBody.md @@ -0,0 +1,17 @@ +# VoucherifySdk::OrdersUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **items** | [**Array<OrderItem>**](OrderItem.md) | Array of items applied to the order. | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | [optional] | +| **referrer** | [**Referrer**](Referrer.md) | | [optional] | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | + diff --git a/docs/OrdersUpdateResponseBody.md b/docs/OrdersUpdateResponseBody.md new file mode 100644 index 00000000..681671d2 --- /dev/null +++ b/docs/OrdersUpdateResponseBody.md @@ -0,0 +1,29 @@ +# VoucherifySdk::OrdersUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | | +| **created_at** | **Time** | Timestamp representing the date and time when the order was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the order was last updated in ISO 8601 format. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **initial_amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **items_discount_amount** | **Integer** | Sum of all product-specific discounts applied to the order. | [optional] | +| **total_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied to the order. | [optional] | +| **total_amount** | **Integer** | Order amount after undoing all the discounts through the rollback redemption. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **items_applied_discount_amount** | **Integer** | Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **items** | [**Array<OrderItemCalculated>**](OrderItemCalculated.md) | Array of items applied to the order. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | | +| **referrer_id** | **String** | Unique referrer ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'order'] | +| **redemptions** | [**Hash<String, OrderRedemptions>**](OrderRedemptions.md) | | [optional] | +| **customer** | [**OrderCalculatedCustomer**](OrderCalculatedCustomer.md) | | [optional] | +| **referrer** | [**OrderCalculatedReferrer**](OrderCalculatedReferrer.md) | | [optional] | + diff --git a/docs/ParameterCampaignType.md b/docs/ParameterCampaignType.md new file mode 100644 index 00000000..d066d7a6 --- /dev/null +++ b/docs/ParameterCampaignType.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterCampaignType + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterCreatedBeforeAfter.md b/docs/ParameterCreatedBeforeAfter.md new file mode 100644 index 00000000..8927678f --- /dev/null +++ b/docs/ParameterCreatedBeforeAfter.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterCreatedBeforeAfter + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **before** | **Time** | Timestamp representing the date and time before the voucher was created in ISO 8601 format. | [optional] | +| **after** | **Time** | Timestamp representing the date and time after the voucher was created in ISO 8601 format. | [optional] | + diff --git a/docs/ParameterExpandListCampaigns.md b/docs/ParameterExpandListCampaigns.md new file mode 100644 index 00000000..6264013f --- /dev/null +++ b/docs/ParameterExpandListCampaigns.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterExpandListCampaigns + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterFiltersListRedemptions.md b/docs/ParameterFiltersListRedemptions.md new file mode 100644 index 00000000..c8efb349 --- /dev/null +++ b/docs/ParameterFiltersListRedemptions.md @@ -0,0 +1,17 @@ +# VoucherifySdk::ParameterFiltersListRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **voucher_code** | [**ParameterFiltersListRedemptionsVoucherCode**](ParameterFiltersListRedemptionsVoucherCode.md) | | [optional] | +| **related_object_id** | [**ParameterFiltersListRedemptionsRelatedObjectId**](ParameterFiltersListRedemptionsRelatedObjectId.md) | | [optional] | +| **related_object_parent_id** | [**ParameterFiltersListRedemptionsRelatedObjectParentId**](ParameterFiltersListRedemptionsRelatedObjectParentId.md) | | [optional] | +| **parent_redemption_id** | [**ParameterFiltersListRedemptionsParentRedemptionId**](ParameterFiltersListRedemptionsParentRedemptionId.md) | | [optional] | +| **failure_code** | [**ParameterFiltersListRedemptionsFailureCode**](ParameterFiltersListRedemptionsFailureCode.md) | | [optional] | +| **result** | [**ParameterFiltersListRedemptionsResult**](ParameterFiltersListRedemptionsResult.md) | | [optional] | +| **object** | [**ParameterFiltersListRedemptionsObject**](ParameterFiltersListRedemptionsObject.md) | | [optional] | +| **customer_id** | [**ParameterFiltersListRedemptionsCustomerId**](ParameterFiltersListRedemptionsCustomerId.md) | | [optional] | +| **campaign_name** | [**ParameterFiltersListRedemptionsCampaignName**](ParameterFiltersListRedemptionsCampaignName.md) | | [optional] | +| **user_login** | [**ParameterFiltersListRedemptionsUserLogin**](ParameterFiltersListRedemptionsUserLogin.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsCampaignName.md b/docs/ParameterFiltersListRedemptionsCampaignName.md new file mode 100644 index 00000000..b4a97f62 --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsCampaignName.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsCampaignName + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsCustomerId.md b/docs/ParameterFiltersListRedemptionsCustomerId.md new file mode 100644 index 00000000..fe0f6c08 --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsCustomerId.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsCustomerId + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsFailureCode.md b/docs/ParameterFiltersListRedemptionsFailureCode.md new file mode 100644 index 00000000..152fed1e --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsFailureCode.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsFailureCode + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsObject.md b/docs/ParameterFiltersListRedemptionsObject.md new file mode 100644 index 00000000..eee296fa --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsObject.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsParentRedemptionId.md b/docs/ParameterFiltersListRedemptionsParentRedemptionId.md new file mode 100644 index 00000000..d5bba7da --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsParentRedemptionId.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsParentRedemptionId + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsRelatedObjectId.md b/docs/ParameterFiltersListRedemptionsRelatedObjectId.md new file mode 100644 index 00000000..7ba481c5 --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsRelatedObjectId.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectId + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsRelatedObjectParentId.md b/docs/ParameterFiltersListRedemptionsRelatedObjectParentId.md new file mode 100644 index 00000000..7296ad9d --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsRelatedObjectParentId.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectParentId + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsResult.md b/docs/ParameterFiltersListRedemptionsResult.md new file mode 100644 index 00000000..fc0bbf26 --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsResult.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsUserLogin.md b/docs/ParameterFiltersListRedemptionsUserLogin.md new file mode 100644 index 00000000..136e95da --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsUserLogin.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsUserLogin + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterFiltersListRedemptionsVoucherCode.md b/docs/ParameterFiltersListRedemptionsVoucherCode.md new file mode 100644 index 00000000..484f7918 --- /dev/null +++ b/docs/ParameterFiltersListRedemptionsVoucherCode.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterFiltersListRedemptionsVoucherCode + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**FilterConditionsString**](FilterConditionsString.md) | | [optional] | +| **junction** | [**Junction**](Junction.md) | | [optional] | + diff --git a/docs/ParameterOrder.md b/docs/ParameterOrder.md new file mode 100644 index 00000000..4d6385a3 --- /dev/null +++ b/docs/ParameterOrder.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListAllPromotionStacks.md b/docs/ParameterOrderListAllPromotionStacks.md new file mode 100644 index 00000000..b76e4a12 --- /dev/null +++ b/docs/ParameterOrderListAllPromotionStacks.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListAllPromotionStacks + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListCampaigns.md b/docs/ParameterOrderListCampaigns.md new file mode 100644 index 00000000..a888fef1 --- /dev/null +++ b/docs/ParameterOrderListCampaigns.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListCampaigns + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListCustomers.md b/docs/ParameterOrderListCustomers.md new file mode 100644 index 00000000..7c1f4e6b --- /dev/null +++ b/docs/ParameterOrderListCustomers.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListCustomers + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListExports.md b/docs/ParameterOrderListExports.md new file mode 100644 index 00000000..c5964028 --- /dev/null +++ b/docs/ParameterOrderListExports.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListExports + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListLoyaltyTiers.md b/docs/ParameterOrderListLoyaltyTiers.md new file mode 100644 index 00000000..f0c82da4 --- /dev/null +++ b/docs/ParameterOrderListLoyaltyTiers.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListLoyaltyTiers + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListOrders.md b/docs/ParameterOrderListOrders.md new file mode 100644 index 00000000..b1b09a9f --- /dev/null +++ b/docs/ParameterOrderListOrders.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListOrders + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListPublications.md b/docs/ParameterOrderListPublications.md new file mode 100644 index 00000000..5de2a50c --- /dev/null +++ b/docs/ParameterOrderListPublications.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListPublications + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListRedemptions.md b/docs/ParameterOrderListRedemptions.md new file mode 100644 index 00000000..c15c1f73 --- /dev/null +++ b/docs/ParameterOrderListRedemptions.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListValidationRuleAssignments.md b/docs/ParameterOrderListValidationRuleAssignments.md new file mode 100644 index 00000000..dba033d5 --- /dev/null +++ b/docs/ParameterOrderListValidationRuleAssignments.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListValidationRuleAssignments + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterOrderListValidationRules.md b/docs/ParameterOrderListValidationRules.md new file mode 100644 index 00000000..4cbf9681 --- /dev/null +++ b/docs/ParameterOrderListValidationRules.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterOrderListValidationRules + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterResultListPublications.md b/docs/ParameterResultListPublications.md new file mode 100644 index 00000000..4b2fb72b --- /dev/null +++ b/docs/ParameterResultListPublications.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterResultListPublications + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/ParameterUpdatedBeforeAfter.md b/docs/ParameterUpdatedBeforeAfter.md new file mode 100644 index 00000000..0c3c45a5 --- /dev/null +++ b/docs/ParameterUpdatedBeforeAfter.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ParameterUpdatedBeforeAfter + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **before** | **Time** | Timestamp representing the date and time before the voucher was updated in ISO 8601 format. | [optional] | +| **after** | **Time** | Timestamp representing the date and time after the voucher was updated in ISO 8601 format. | [optional] | + diff --git a/docs/ParameterVoucherTypeListPublications.md b/docs/ParameterVoucherTypeListPublications.md new file mode 100644 index 00000000..301ac5c8 --- /dev/null +++ b/docs/ParameterVoucherTypeListPublications.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ParameterVoucherTypeListPublications + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/PointsExpirationTypes.md b/docs/PointsExpirationTypes.md new file mode 100644 index 00000000..54ab2e38 --- /dev/null +++ b/docs/PointsExpirationTypes.md @@ -0,0 +1,7 @@ +# VoucherifySdk::PointsExpirationTypes + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/Product.md b/docs/Product.md new file mode 100644 index 00000000..acc0d332 --- /dev/null +++ b/docs/Product.md @@ -0,0 +1,18 @@ +# VoucherifySdk::Product + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID assigned by Voucherify. | | +| **source_id** | **String** | Unique product source ID. | | +| **name** | **String** | Unique user-defined product name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the product was updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the product. | [default to 'product'] | +| **skus** | [**SkusListForProduct**](SkusListForProduct.md) | | [optional] | + diff --git a/docs/ProductCollectionsApi.md b/docs/ProductCollectionsApi.md new file mode 100644 index 00000000..2a020cc5 --- /dev/null +++ b/docs/ProductCollectionsApi.md @@ -0,0 +1,319 @@ +# VoucherifySdk::ProductCollectionsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_product_collection**](ProductCollectionsApi.md#create_product_collection) | **POST** /v1/product-collections | Create Product Collection | +| [**delete_product_collection**](ProductCollectionsApi.md#delete_product_collection) | **DELETE** /v1/product-collections/{productCollectionId} | Delete Product Collection | +| [**get_product_collection**](ProductCollectionsApi.md#get_product_collection) | **GET** /v1/product-collections/{productCollectionId} | Get Product Collection | +| [**list_product_collections**](ProductCollectionsApi.md#list_product_collections) | **GET** /v1/product-collections | List Product Collections | +| [**list_products_in_collection**](ProductCollectionsApi.md#list_products_in_collection) | **GET** /v1/product-collections/{productCollectionId}/products | List Products in Collection | + + +## create_product_collection + +> create_product_collection(opts) + +Create Product Collection + +This method creates a new product collection. + +### 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::ProductCollectionsApi.new +opts = { + product_collections_create_request_body: VoucherifySdk::ProductCollectionsCreateDynamicRequestBody.new({type: 'AUTO_UPDATE', name: 'name_example', filter: VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyFilter.new({junction: VoucherifySdk::Junction::AND})}) # ProductCollectionsCreateRequestBody | +} + +begin + # Create Product Collection + result = api_instance.create_product_collection(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductCollectionsApi->create_product_collection: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_collections_create_request_body** | [**ProductCollectionsCreateRequestBody**](ProductCollectionsCreateRequestBody.md) | | [optional] | + +### Return type + +[**ProductCollectionsCreateResponseBody**](ProductCollectionsCreateResponseBody.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 + + +## delete_product_collection + +> delete_product_collection(product_collection_id) + +Delete Product Collection + +This method deletes a product collection. + +### 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::ProductCollectionsApi.new +product_collection_id = 'product_collection_id_example' # String | A unique product collection ID. + +begin + # Delete Product Collection + api_instance.delete_product_collection(product_collection_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductCollectionsApi->delete_product_collection: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_collection_id** | **String** | A unique product collection ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## get_product_collection + +> get_product_collection(product_collection_id) + +Get Product Collection + +Retrieves the product collection. + +### 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::ProductCollectionsApi.new +product_collection_id = 'product_collection_id_example' # String | A unique product collection ID. + +begin + # Get Product Collection + result = api_instance.get_product_collection(product_collection_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductCollectionsApi->get_product_collection: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_collection_id** | **String** | A unique product collection ID. | | + +### Return type + +[**ProductCollectionsGetResponseBody**](ProductCollectionsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_product_collections + +> list_product_collections(opts) + +List Product Collections + +This method returns a list of product collections. + +### 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::ProductCollectionsApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrder::CREATED_AT # ParameterOrder | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. +} + +begin + # List Product Collections + result = api_instance.list_product_collections(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductCollectionsApi->list_product_collections: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrder**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | + +### Return type + +[**ProductCollectionsListResponseBody**](ProductCollectionsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_products_in_collection + +> list_products_in_collection(product_collection_id, opts) + +List Products in Collection + +Retrieves list of products from a product collection; works for both dynamic and static product collections. + +### 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::ProductCollectionsApi.new +product_collection_id = 'product_collection_id_example' # String | Unique product collection ID. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrder::CREATED_AT, # ParameterOrder | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + starting_after: Time.parse('2013-10-20T19:20:30+01:00') # Time | Timestamp representing the date and time to use in starting_after cursor to get more data. Represented in ISO 8601 format. +} + +begin + # List Products in Collection + result = api_instance.list_products_in_collection(product_collection_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductCollectionsApi->list_products_in_collection: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_collection_id** | **String** | Unique product collection ID. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrder**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **starting_after** | **Time** | Timestamp representing the date and time to use in starting_after cursor to get more data. Represented in ISO 8601 format. | [optional] | + +### Return type + +[**ProductCollectionsProductsListResponseBody**](ProductCollectionsProductsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/ProductCollectionsCreateDynamicRequestBody.md b/docs/ProductCollectionsCreateDynamicRequestBody.md new file mode 100644 index 00000000..20b62c3f --- /dev/null +++ b/docs/ProductCollectionsCreateDynamicRequestBody.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ProductCollectionsCreateDynamicRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Show that the product collection is dynamic (products come in and leave based on set criteria). | [default to 'AUTO_UPDATE'] | +| **name** | **String** | Unique user-defined product collection name. | | +| **filter** | [**ProductCollectionsCreateDynamicRequestBodyFilter**](ProductCollectionsCreateDynamicRequestBodyFilter.md) | | | + diff --git a/docs/ProductCollectionsCreateDynamicRequestBodyFilter.md b/docs/ProductCollectionsCreateDynamicRequestBodyFilter.md new file mode 100644 index 00000000..18b91215 --- /dev/null +++ b/docs/ProductCollectionsCreateDynamicRequestBodyFilter.md @@ -0,0 +1,20 @@ +# VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyFilter + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | | +| **id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **product_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **source_id** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **name** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **price** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **object** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **attributes** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **metadata** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **image_url** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **skus** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **created_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | +| **updated_at** | [**FieldConditions**](FieldConditions.md) | | [optional] | + diff --git a/docs/ProductCollectionsCreateDynamicRequestBodyProductsItem.md b/docs/ProductCollectionsCreateDynamicRequestBodyProductsItem.md new file mode 100644 index 00000000..83f13f30 --- /dev/null +++ b/docs/ProductCollectionsCreateDynamicRequestBodyProductsItem.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyProductsItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The product ID. | | +| **product_id** | **String** | Product ID for SKUs. | [optional] | +| **object** | **String** | Denotes the type of object represented by the ID. | | + diff --git a/docs/ProductCollectionsCreateRequestBody.md b/docs/ProductCollectionsCreateRequestBody.md new file mode 100644 index 00000000..03461f1c --- /dev/null +++ b/docs/ProductCollectionsCreateRequestBody.md @@ -0,0 +1,49 @@ +# VoucherifySdk::ProductCollectionsCreateRequestBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ProductCollectionsCreateRequestBody.openapi_one_of +# => +# [ +# :'ProductCollectionsCreateDynamicRequestBody', +# :'ProductCollectionsCreateStaticRequestBody' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ProductCollectionsCreateRequestBody.build(data) +# => # + +VoucherifySdk::ProductCollectionsCreateRequestBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ProductCollectionsCreateDynamicRequestBody` +- `ProductCollectionsCreateStaticRequestBody` +- `nil` (if no type matches) + diff --git a/docs/ProductCollectionsCreateResponseBody.md b/docs/ProductCollectionsCreateResponseBody.md new file mode 100644 index 00000000..bae7cac0 --- /dev/null +++ b/docs/ProductCollectionsCreateResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ProductCollectionsCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Product collection ID. | | +| **name** | **String** | Unique user-defined product collection name. | | +| **type** | **String** | Describes whether the product collection is dynamic (products come in and leave based on set criteria) or static (manually selected products). | | +| **filter** | [**ProductCollectionsCreateDynamicRequestBodyFilter**](ProductCollectionsCreateDynamicRequestBodyFilter.md) | | [optional] | +| **products** | [**Array<ProductCollectionsItemProductsItem>**](ProductCollectionsItemProductsItem.md) | Defines a set of products for a `STATIC` product collection type. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product collection was created in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the static product collection. | [default to 'products_collection'] | + diff --git a/docs/ProductCollectionsCreateStaticRequestBody.md b/docs/ProductCollectionsCreateStaticRequestBody.md new file mode 100644 index 00000000..ec6e107b --- /dev/null +++ b/docs/ProductCollectionsCreateStaticRequestBody.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ProductCollectionsCreateStaticRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Show that the product collection is static (manually selected products). | [default to 'STATIC'] | +| **name** | **String** | Unique user-defined product collection name. | | +| **products** | [**Array<ProductCollectionsCreateDynamicRequestBodyProductsItem>**](ProductCollectionsCreateDynamicRequestBodyProductsItem.md) | Defines a set of products for a `STATIC` product collection type. | [optional] | + diff --git a/docs/ProductCollectionsGetResponseBody.md b/docs/ProductCollectionsGetResponseBody.md new file mode 100644 index 00000000..cb485064 --- /dev/null +++ b/docs/ProductCollectionsGetResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ProductCollectionsGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Product collection ID. | | +| **name** | **String** | Unique user-defined product collection name. | | +| **type** | **String** | Describes whether the product collection is dynamic (products come in and leave based on set criteria) or static (manually selected products). | | +| **filter** | [**ProductCollectionsCreateDynamicRequestBodyFilter**](ProductCollectionsCreateDynamicRequestBodyFilter.md) | | [optional] | +| **products** | [**Array<ProductCollectionsItemProductsItem>**](ProductCollectionsItemProductsItem.md) | Defines a set of products for a `STATIC` product collection type. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product collection was created in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the static product collection. | [default to 'products_collection'] | + diff --git a/docs/ProductCollectionsItem.md b/docs/ProductCollectionsItem.md new file mode 100644 index 00000000..2ffba218 --- /dev/null +++ b/docs/ProductCollectionsItem.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ProductCollectionsItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Product collection ID. | | +| **name** | **String** | Unique user-defined product collection name. | | +| **type** | **String** | Describes whether the product collection is dynamic (products come in and leave based on set criteria) or static (manually selected products). | | +| **filter** | [**ProductCollectionsCreateDynamicRequestBodyFilter**](ProductCollectionsCreateDynamicRequestBodyFilter.md) | | [optional] | +| **products** | [**Array<ProductCollectionsItemProductsItem>**](ProductCollectionsItemProductsItem.md) | Defines a set of products for a `STATIC` product collection type. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product collection was created in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the static product collection. | [default to 'products_collection'] | + diff --git a/docs/ProductCollectionsItemProductsItem.md b/docs/ProductCollectionsItemProductsItem.md new file mode 100644 index 00000000..6bdf11bb --- /dev/null +++ b/docs/ProductCollectionsItemProductsItem.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ProductCollectionsItemProductsItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The product ID. | | +| **product_id** | **String** | Product ID for SKUs. | [optional] | +| **object** | **String** | Denotes the type of object represented by the ID. | | + diff --git a/docs/ProductCollectionsList.md b/docs/ProductCollectionsList.md new file mode 100644 index 00000000..217f06cb --- /dev/null +++ b/docs/ProductCollectionsList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ProductCollectionsList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about product collections. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of product collections. | [default to 'data'] | +| **data** | [**Array<ProductCollectionsItem>**](ProductCollectionsItem.md) | A dictionary that contains an array of product collections and their details. | | +| **total** | **Integer** | Total number of product collections. | | + diff --git a/docs/ProductCollectionsListResponseBody.md b/docs/ProductCollectionsListResponseBody.md new file mode 100644 index 00000000..e7b28025 --- /dev/null +++ b/docs/ProductCollectionsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ProductCollectionsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about product collections. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of product collections. | [default to 'data'] | +| **data** | [**Array<ProductCollectionsItem>**](ProductCollectionsItem.md) | A dictionary that contains an array of product collections and their details. | | +| **total** | **Integer** | Total number of product collections. | | + diff --git a/docs/ProductCollectionsProductsList.md b/docs/ProductCollectionsProductsList.md new file mode 100644 index 00000000..54347bbe --- /dev/null +++ b/docs/ProductCollectionsProductsList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ProductCollectionsProductsList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about products and SKUs. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of products and SKUs. | [default to 'data'] | +| **data** | [**Array<ProductCollectionsProductsListProductsItem>**](ProductCollectionsProductsListProductsItem.md) | A dictionary that contains an array of products and SKUs. | | +| **total** | **Integer** | Total number of products & SKUs in the product collection. | | + diff --git a/docs/ProductCollectionsProductsListProductsItem.md b/docs/ProductCollectionsProductsListProductsItem.md new file mode 100644 index 00000000..0689433d --- /dev/null +++ b/docs/ProductCollectionsProductsListProductsItem.md @@ -0,0 +1,49 @@ +# VoucherifySdk::ProductCollectionsProductsListProductsItem + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ProductCollectionsProductsListProductsItem.openapi_one_of +# => +# [ +# :'ProductWithoutSkus', +# :'SkuWithProduct' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ProductCollectionsProductsListProductsItem.build(data) +# => # + +VoucherifySdk::ProductCollectionsProductsListProductsItem.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ProductWithoutSkus` +- `SkuWithProduct` +- `nil` (if no type matches) + diff --git a/docs/ProductCollectionsProductsListResponseBody.md b/docs/ProductCollectionsProductsListResponseBody.md new file mode 100644 index 00000000..10d883cd --- /dev/null +++ b/docs/ProductCollectionsProductsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ProductCollectionsProductsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about products and SKUs. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of products and SKUs. | [default to 'data'] | +| **data** | [**Array<ProductCollectionsProductsListProductsItem>**](ProductCollectionsProductsListProductsItem.md) | A dictionary that contains an array of products and SKUs. | | +| **total** | **Integer** | Total number of products & SKUs in the product collection. | | + diff --git a/docs/ProductWithoutSkus.md b/docs/ProductWithoutSkus.md new file mode 100644 index 00000000..81455ecb --- /dev/null +++ b/docs/ProductWithoutSkus.md @@ -0,0 +1,17 @@ +# VoucherifySdk::ProductWithoutSkus + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID assigned by Voucherify. | | +| **source_id** | **String** | Unique product source ID. | | +| **name** | **String** | Unique user-defined product name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the product was updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the product. | [default to 'product'] | + diff --git a/docs/ProductsApi.md b/docs/ProductsApi.md new file mode 100644 index 00000000..422a0ada --- /dev/null +++ b/docs/ProductsApi.md @@ -0,0 +1,883 @@ +# VoucherifySdk::ProductsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_product**](ProductsApi.md#create_product) | **POST** /v1/products | Create Product | +| [**create_sku**](ProductsApi.md#create_sku) | **POST** /v1/products/{productId}/skus | Create SKU | +| [**delete_product**](ProductsApi.md#delete_product) | **DELETE** /v1/products/{productId} | Delete Product | +| [**delete_sku**](ProductsApi.md#delete_sku) | **DELETE** /v1/products/{productId}/skus/{skuId} | Delete SKU | +| [**get_product**](ProductsApi.md#get_product) | **GET** /v1/products/{productId} | Get Product | +| [**get_sku**](ProductsApi.md#get_sku) | **GET** /v1/skus/{skuId} | Get SKU | +| [**import_products_using_csv**](ProductsApi.md#import_products_using_csv) | **POST** /v1/products/importCSV | Import Products using CSV | +| [**import_skus_using_csv**](ProductsApi.md#import_skus_using_csv) | **POST** /v1/skus/importCSV | Import SKUs using CSV | +| [**list_products**](ProductsApi.md#list_products) | **GET** /v1/products | List Products | +| [**list_skus_in_product**](ProductsApi.md#list_skus_in_product) | **GET** /v1/products/{productId}/skus | List SKUs in Product | +| [**update_product**](ProductsApi.md#update_product) | **PUT** /v1/products/{productId} | Update Product | +| [**update_products_in_bulk**](ProductsApi.md#update_products_in_bulk) | **POST** /v1/products/bulk/async | Update Products in bulk | +| [**update_products_metadata_in_bulk**](ProductsApi.md#update_products_metadata_in_bulk) | **POST** /v1/products/metadata/async | Update Products' Metadata in bulk | +| [**update_sku**](ProductsApi.md#update_sku) | **PUT** /v1/products/{productId}/skus/{skuId} | Update SKU | + + +## create_product + +> create_product(opts) + +Create Product + +Creates a product object. 📘 Upsert Mode If you pass an id or a source_id that already exists in the product database, Voucherify will return a related product object with updated fields. + +### 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::ProductsApi.new +opts = { + products_create_request_body: VoucherifySdk::ProductsCreateRequestBody.new # ProductsCreateRequestBody | Specify the product parameters. +} + +begin + # Create Product + result = api_instance.create_product(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->create_product: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **products_create_request_body** | [**ProductsCreateRequestBody**](ProductsCreateRequestBody.md) | Specify the product parameters. | [optional] | + +### Return type + +[**ProductsCreateResponseBody**](ProductsCreateResponseBody.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_sku + +> create_sku(product_id, opts) + +Create SKU + +This method adds product variants to a created product. 📘 Upsert Mode If you pass an id or a source_id that already exists in the sku database, Voucherify will return a related sku object with updated fields. + +### 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::ProductsApi.new +product_id = 'product_id_example' # String | A Voucherify product ID or product source ID. +opts = { + products_skus_create_request_body: VoucherifySdk::ProductsSkusCreateRequestBody.new # ProductsSkusCreateRequestBody | Specify the SKU parameters to be created. +} + +begin + # Create SKU + result = api_instance.create_sku(product_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->create_sku: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_id** | **String** | A Voucherify product ID or product source ID. | | +| **products_skus_create_request_body** | [**ProductsSkusCreateRequestBody**](ProductsSkusCreateRequestBody.md) | Specify the SKU parameters to be created. | [optional] | + +### Return type + +[**ProductsSkusCreateResponseBody**](ProductsSkusCreateResponseBody.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 + + +## delete_product + +> delete_product(product_id, opts) + +Delete Product + +This method deletes a product. + +### 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::ProductsApi.new +product_id = 'product_id_example' # String | A Voucherify product ID or source ID. +opts = { + force: true # Boolean | If this flag is set to true, the product will be removed permanently. Going forward, the user will be able to create another product with exactly the same source_id. +} + +begin + # Delete Product + api_instance.delete_product(product_id, opts) +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->delete_product: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_id** | **String** | A Voucherify product ID or source ID. | | +| **force** | **Boolean** | If this flag is set to true, the product will be removed permanently. Going forward, the user will be able to create another product with exactly the same source_id. | [optional] | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## delete_sku + +> delete_sku(product_id, sku_id, opts) + +Delete SKU + +This method deletes a product SKU. + +### 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::ProductsApi.new +product_id = 'product_id_example' # String | A unique Voucherify product ID or product source ID. +sku_id = 'sku_id_example' # String | A Voucherify SKU ID or SKU source ID. +opts = { + force: true # Boolean | If this flag is set to true, the SKU will be removed permanently. Going forward, the user will be able to create another SKU with exactly the same source_id. +} + +begin + # Delete SKU + api_instance.delete_sku(product_id, sku_id, opts) +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->delete_sku: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_id** | **String** | A unique Voucherify product ID or product source ID. | | +| **sku_id** | **String** | A Voucherify SKU ID or SKU source ID. | | +| **force** | **Boolean** | If this flag is set to true, the SKU will be removed permanently. Going forward, the user will be able to create another SKU with exactly the same source_id. | [optional] | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## get_product + +> get_product(product_id) + +Get Product + +Retrieve product details. + +### 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::ProductsApi.new +product_id = 'product_id_example' # String | A Voucherify product ID or source ID. + +begin + # Get Product + result = api_instance.get_product(product_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->get_product: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_id** | **String** | A Voucherify product ID or source ID. | | + +### Return type + +[**ProductsGetResponseBody**](ProductsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_sku + +> get_sku(sku_id) + +Get SKU + +Retrieve details of a SKU. + +### 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::ProductsApi.new +sku_id = 'sku_id_example' # String | A Voucherify SKU identifier or SKU source ID. + +begin + # Get SKU + result = api_instance.get_sku(sku_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->get_sku: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **sku_id** | **String** | A Voucherify SKU identifier or SKU source ID. | | + +### Return type + +[**SkusGetResponseBody**](SkusGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## import_products_using_csv + +> import_products_using_csv(file) + +Import Products using CSV + +Import products into the repository using a CSV file. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::ProductsApi.new +file = File.new('/path/to/some/file') # File | File path. + +begin + # Import Products using CSV + result = api_instance.import_products_using_csv(file) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->import_products_using_csv: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **file** | **File** | File path. | | + +### Return type + +[**ProductsImportCsvCreateResponseBody**](ProductsImportCsvCreateResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + + +## import_skus_using_csv + +> import_skus_using_csv(file) + +Import SKUs using CSV + +Import SKUs into the repository using a CSV file. The CSV file has to include headers in the first line. All properties which cannot be mapped to standard SKU fields will be added to the metadata object. You can find an example template [here](https://s3.amazonaws.com/helpscout.net/docs/assets/5902f1c12c7d3a057f88a36d/attachments/627b98d08c9b585083488a4c/Import_SKUS_template.csv). This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::ProductsApi.new +file = File.new('/path/to/some/file') # File | File path. + +begin + # Import SKUs using CSV + result = api_instance.import_skus_using_csv(file) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->import_skus_using_csv: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **file** | **File** | File path. | | + +### Return type + +[**SkusImportCsvCreateResponseBody**](SkusImportCsvCreateResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + + +## list_products + +> list_products(opts) + +List Products + +Retrieve a list of products. + +### 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::ProductsApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrder::CREATED_AT, # ParameterOrder | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + start_date: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + end_date: Time.parse('2013-10-20T19:20:30+01:00') # Time | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. +} + +begin + # List Products + result = api_instance.list_products(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->list_products: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrder**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **start_date** | **Time** | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. | [optional] | +| **end_date** | **Time** | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. | [optional] | + +### Return type + +[**ProductsListResponseBody**](ProductsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_skus_in_product + +> list_skus_in_product(product_id, opts) + +List SKUs in Product + +Retrieve all SKUs for a given product. + +### 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::ProductsApi.new +product_id = 'product_id_example' # String | A Voucherify product ID or product source ID. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrder::CREATED_AT, # ParameterOrder | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + start_date: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + end_date: Time.parse('2013-10-20T19:20:30+01:00') # Time | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. +} + +begin + # List SKUs in Product + result = api_instance.list_skus_in_product(product_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->list_skus_in_product: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_id** | **String** | A Voucherify product ID or product source ID. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrder**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **start_date** | **Time** | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. | [optional] | +| **end_date** | **Time** | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. | [optional] | + +### Return type + +[**ProductsSkusListResponseBody**](ProductsSkusListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_product + +> update_product(product_id, opts) + +Update Product + +Updates the specified product by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. + +### 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::ProductsApi.new +product_id = 'product_id_example' # String | A Voucherify product ID or source ID. +opts = { + products_update_request_body: VoucherifySdk::ProductsUpdateRequestBody.new # ProductsUpdateRequestBody | Specify the parameters of the product that are to be updated. +} + +begin + # Update Product + result = api_instance.update_product(product_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->update_product: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_id** | **String** | A Voucherify product ID or source ID. | | +| **products_update_request_body** | [**ProductsUpdateRequestBody**](ProductsUpdateRequestBody.md) | Specify the parameters of the product that are to be updated. | [optional] | + +### Return type + +[**ProductsUpdateResponseBody**](ProductsUpdateResponseBody.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 + + +## update_products_in_bulk + +> update_products_in_bulk(opts) + +Update Products in bulk + +Update several products in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested product object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::ProductsApi.new +opts = { + products_update_in_bulk_request_body: [VoucherifySdk::ProductsUpdateInBulkRequestBody.new({source_id: 'test_prod_id_1'})] # Array | Create an array of product objects, each with the parameters which you want to update. +} + +begin + # Update Products in bulk + result = api_instance.update_products_in_bulk(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->update_products_in_bulk: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **products_update_in_bulk_request_body** | [**Array<ProductsUpdateInBulkRequestBody>**](ProductsUpdateInBulkRequestBody.md) | Create an array of product objects, each with the parameters which you want to update. | [optional] | + +### Return type + +[**ProductsUpdateInBulkResponseBody**](ProductsUpdateInBulkResponseBody.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 + + +## update_products_metadata_in_bulk + +> update_products_metadata_in_bulk(opts) + +Update Products' Metadata in bulk + +Update several product metadata properties in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested product object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::ProductsApi.new +opts = { + products_metadata_update_in_bulk_request_body: VoucherifySdk::ProductsMetadataUpdateInBulkRequestBody.new({source_ids: ['source_ids_example'], metadata: 3.56}) # ProductsMetadataUpdateInBulkRequestBody | Specify the list of product source IDs and the metadata key value pairs to be udpated for these products. +} + +begin + # Update Products' Metadata in bulk + result = api_instance.update_products_metadata_in_bulk(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->update_products_metadata_in_bulk: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **products_metadata_update_in_bulk_request_body** | [**ProductsMetadataUpdateInBulkRequestBody**](ProductsMetadataUpdateInBulkRequestBody.md) | Specify the list of product source IDs and the metadata key value pairs to be udpated for these products. | [optional] | + +### Return type + +[**ProductsMetadataUpdateInBulkResponseBody**](ProductsMetadataUpdateInBulkResponseBody.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 + + +## update_sku + +> update_sku(product_id, sku_id, opts) + +Update SKU + +Updates the specified SKU by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. Fields other than the ones listed in the request body schema wont be modified. Even if provided, they will be silently skipped. + +### 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::ProductsApi.new +product_id = 'product_id_example' # String | A unique Voucherify product ID or product source ID. +sku_id = 'sku_id_example' # String | A Voucherify SKU ID or SKU source ID. +opts = { + products_skus_update_request_body: VoucherifySdk::ProductsSkusUpdateRequestBody.new # ProductsSkusUpdateRequestBody | Specify the parameters to be updated. +} + +begin + # Update SKU + result = api_instance.update_sku(product_id, sku_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ProductsApi->update_sku: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product_id** | **String** | A unique Voucherify product ID or product source ID. | | +| **sku_id** | **String** | A Voucherify SKU ID or SKU source ID. | | +| **products_skus_update_request_body** | [**ProductsSkusUpdateRequestBody**](ProductsSkusUpdateRequestBody.md) | Specify the parameters to be updated. | [optional] | + +### Return type + +[**ProductsSkusUpdateResponseBody**](ProductsSkusUpdateResponseBody.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 + diff --git a/docs/ProductsCreateRequestBody.md b/docs/ProductsCreateRequestBody.md new file mode 100644 index 00000000..b897fa11 --- /dev/null +++ b/docs/ProductsCreateRequestBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ProductsCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the product and is assigned by Voucherify. | [optional] | +| **source_id** | **String** | Unique product source ID. | [optional] | +| **name** | **String** | Unique user-defined product name. | [optional] | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | [optional] | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | [optional] | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | + diff --git a/docs/ProductsCreateResponseBody.md b/docs/ProductsCreateResponseBody.md new file mode 100644 index 00000000..82448bc5 --- /dev/null +++ b/docs/ProductsCreateResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::ProductsCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID assigned by Voucherify. | | +| **source_id** | **String** | Unique product source ID. | | +| **name** | **String** | Unique user-defined product name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the product was updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the product. | [default to 'product'] | +| **skus** | [**SkusListForProduct**](SkusListForProduct.md) | | [optional] | + diff --git a/docs/ProductsGetResponseBody.md b/docs/ProductsGetResponseBody.md new file mode 100644 index 00000000..12e6d10c --- /dev/null +++ b/docs/ProductsGetResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::ProductsGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID assigned by Voucherify. | | +| **source_id** | **String** | Unique product source ID. | | +| **name** | **String** | Unique user-defined product name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the product was updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the product. | [default to 'product'] | +| **skus** | [**SkusListForProduct**](SkusListForProduct.md) | | [optional] | + diff --git a/docs/ProductsImportCsvCreateResponseBody.md b/docs/ProductsImportCsvCreateResponseBody.md new file mode 100644 index 00000000..cf6a8028 --- /dev/null +++ b/docs/ProductsImportCsvCreateResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ProductsImportCsvCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/ProductsListResponseBody.md b/docs/ProductsListResponseBody.md new file mode 100644 index 00000000..5543fcbf --- /dev/null +++ b/docs/ProductsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ProductsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about products in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of product objects. | [default to 'products'] | +| **products** | [**Array<Product>**](Product.md) | Contains array of product objects. | | +| **total** | **Integer** | Total number of product objects. | | + diff --git a/docs/ProductsMetadataUpdateInBulkRequestBody.md b/docs/ProductsMetadataUpdateInBulkRequestBody.md new file mode 100644 index 00000000..8860c912 --- /dev/null +++ b/docs/ProductsMetadataUpdateInBulkRequestBody.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ProductsMetadataUpdateInBulkRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **source_ids** | **Array<String>** | Array of unique product source IDs. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | | + diff --git a/docs/ProductsMetadataUpdateInBulkResponseBody.md b/docs/ProductsMetadataUpdateInBulkResponseBody.md new file mode 100644 index 00000000..8f3e0722 --- /dev/null +++ b/docs/ProductsMetadataUpdateInBulkResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ProductsMetadataUpdateInBulkResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/ProductsSkusCreateRequestBody.md b/docs/ProductsSkusCreateRequestBody.md new file mode 100644 index 00000000..69f946a2 --- /dev/null +++ b/docs/ProductsSkusCreateRequestBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::ProductsSkusCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique SKU ID. | [optional] | +| **source_id** | **String** | A unique SKU identifier from your inventory system. | [optional] | +| **sku** | **String** | Unique user-defined SKU name. | [optional] | +| **price** | **Integer** | SKU unit price. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [optional] | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | [optional] | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | [optional] | + diff --git a/docs/ProductsSkusCreateResponseBody.md b/docs/ProductsSkusCreateResponseBody.md new file mode 100644 index 00000000..2cd7546a --- /dev/null +++ b/docs/ProductsSkusCreateResponseBody.md @@ -0,0 +1,19 @@ +# VoucherifySdk::ProductsSkusCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the SKU and is assigned by Voucherify. | | +| **source_id** | **String** | A unique SKU identifier from your inventory system. | | +| **product_id** | **String** | The parent product's unique ID. | | +| **sku** | **String** | Unique user-defined SKU name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the SKU was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the SKU was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the `SKU`. | [default to 'sku'] | + diff --git a/docs/ProductsSkusListResponseBody.md b/docs/ProductsSkusListResponseBody.md new file mode 100644 index 00000000..a060691a --- /dev/null +++ b/docs/ProductsSkusListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ProductsSkusListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about SKUs. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of SKUs. | [default to 'data'] | +| **skus** | [**Array<Sku>**](Sku.md) | A dictionary that contains an array of SKUs. | | +| **total** | **Integer** | Total number of SKUs in the product. | | + diff --git a/docs/ProductsSkusUpdateRequestBody.md b/docs/ProductsSkusUpdateRequestBody.md new file mode 100644 index 00000000..9349f6ed --- /dev/null +++ b/docs/ProductsSkusUpdateRequestBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::ProductsSkusUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **sku** | **String** | Unique user-defined SKU name. | [optional] | +| **price** | **Integer** | SKU unit price. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [optional] | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | [optional] | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | [optional] | + diff --git a/docs/ProductsSkusUpdateResponseBody.md b/docs/ProductsSkusUpdateResponseBody.md new file mode 100644 index 00000000..e34a6306 --- /dev/null +++ b/docs/ProductsSkusUpdateResponseBody.md @@ -0,0 +1,19 @@ +# VoucherifySdk::ProductsSkusUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the SKU and is assigned by Voucherify. | | +| **source_id** | **String** | A unique SKU identifier from your inventory system. | | +| **product_id** | **String** | The parent product's unique ID. | | +| **sku** | **String** | Unique user-defined SKU name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the SKU was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the SKU was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the `SKU`. | [default to 'sku'] | + diff --git a/docs/ProductsUpdateInBulkRequestBody.md b/docs/ProductsUpdateInBulkRequestBody.md new file mode 100644 index 00000000..9c7e80be --- /dev/null +++ b/docs/ProductsUpdateInBulkRequestBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::ProductsUpdateInBulkRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **source_id** | **String** | Unique product source ID from your inventory system. | | +| **name** | **String** | Unique user-defined product name. | [optional] | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | [optional] | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | [optional] | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | [optional] | + diff --git a/docs/ProductsUpdateInBulkResponseBody.md b/docs/ProductsUpdateInBulkResponseBody.md new file mode 100644 index 00000000..024e90fb --- /dev/null +++ b/docs/ProductsUpdateInBulkResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ProductsUpdateInBulkResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/ProductsUpdateRequestBody.md b/docs/ProductsUpdateRequestBody.md new file mode 100644 index 00000000..bbfa406f --- /dev/null +++ b/docs/ProductsUpdateRequestBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::ProductsUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Unique user-defined product name. | [optional] | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | [optional] | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | [optional] | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | + diff --git a/docs/ProductsUpdateResponseBody.md b/docs/ProductsUpdateResponseBody.md new file mode 100644 index 00000000..86f14961 --- /dev/null +++ b/docs/ProductsUpdateResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::ProductsUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID assigned by Voucherify. | | +| **source_id** | **String** | Unique product source ID. | | +| **name** | **String** | Unique user-defined product name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the product was updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the product. | [default to 'product'] | +| **skus** | [**SkusListForProduct**](SkusListForProduct.md) | | [optional] | + diff --git a/docs/PromotionStack.md b/docs/PromotionStack.md new file mode 100644 index 00000000..e63704a0 --- /dev/null +++ b/docs/PromotionStack.md @@ -0,0 +1,16 @@ +# VoucherifySdk::PromotionStack + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Promotion stack name. | | +| **tiers** | [**PromotionStackBaseTiers**](PromotionStackBaseTiers.md) | | | +| **id** | **String** | Unique promotion stack ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the promotion stack was updated in ISO 8601 format. | [optional] | +| **campaign_id** | **String** | Promotion stack's parent campaign's unique ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'promotion_stack'] | +| **category_id** | **String** | Promotion stack category ID. | | +| **categories** | [**Array<Category>**](Category.md) | Details about the category assigned to the promotion stack. | | + diff --git a/docs/PromotionStackBase.md b/docs/PromotionStackBase.md new file mode 100644 index 00000000..b5a29bb6 --- /dev/null +++ b/docs/PromotionStackBase.md @@ -0,0 +1,9 @@ +# VoucherifySdk::PromotionStackBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Promotion stack name. | | +| **tiers** | [**PromotionStackBaseTiers**](PromotionStackBaseTiers.md) | | | + diff --git a/docs/PromotionStackBaseTiers.md b/docs/PromotionStackBaseTiers.md new file mode 100644 index 00000000..e2b1f378 --- /dev/null +++ b/docs/PromotionStackBaseTiers.md @@ -0,0 +1,9 @@ +# VoucherifySdk::PromotionStackBaseTiers + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **ids** | **Array<String>** | Contains the list of tiers in a pre-defined sequence. | | +| **hierarchy_mode** | **String** | | [optional][default to 'MANUAL'] | + diff --git a/docs/PromotionTier.md b/docs/PromotionTier.md new file mode 100644 index 00000000..7c143425 --- /dev/null +++ b/docs/PromotionTier.md @@ -0,0 +1,28 @@ +# VoucherifySdk::PromotionTier + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique promotion tier ID. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. | [optional] | +| **name** | **String** | Name of the promotion tier. | [optional] | +| **banner** | **String** | Text to be displayed to your customers on your website. | [optional] | +| **action** | [**PromotionTierAction**](PromotionTierAction.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. | [optional] | +| **hierarchy** | **Integer** | The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. | [optional] | +| **promotion_id** | **String** | Promotion unique ID. | [optional] | +| **campaign** | [**PromotionTierCampaign**](PromotionTierCampaign.md) | | [optional] | +| **campaign_id** | **String** | Promotion tier's parent campaign's unique ID. | [optional] | +| **active** | **Boolean** | A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**PromotionTierValidityTimeframe**](PromotionTierValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **summary** | [**PromotionTierSummary**](PromotionTierSummary.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the promotion tier. | [optional][default to 'promotion_tier'] | +| **validation_rule_assignments** | [**ValidationRuleAssignmentsList**](ValidationRuleAssignmentsList.md) | | [optional] | +| **category_id** | **String** | Promotion tier category ID. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | | [optional] | + diff --git a/docs/PromotionTierAction.md b/docs/PromotionTierAction.md new file mode 100644 index 00000000..a51cb8c0 --- /dev/null +++ b/docs/PromotionTierAction.md @@ -0,0 +1,8 @@ +# VoucherifySdk::PromotionTierAction + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **discount** | [**Discount**](Discount.md) | | [optional] | + diff --git a/docs/PromotionTierCampaign.md b/docs/PromotionTierCampaign.md new file mode 100644 index 00000000..2d62fe92 --- /dev/null +++ b/docs/PromotionTierCampaign.md @@ -0,0 +1,15 @@ +# VoucherifySdk::PromotionTierCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**PromotionTierCampaignValidityTimeframe**](PromotionTierCampaignValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **active** | **Boolean** | A flag indicating whether the campaign is active or not active. A campaign can be disabled even though it's within the active period defined by the `start_date` and `expiration_date` using the <!-- [Disable Campaign](OpenAPI.json/paths/~1campaigns~1{campaignId}~1disable) -->[Disable Campaign](ref:disable-campaign) endpoint. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign | [optional] | +| **category_id** | **String** | Unique category ID that this campaign belongs to. | [optional] | +| **object** | **String** | The type of object represented by the campaign object. This object stores information about the campaign. | [optional][default to 'campaign'] | + diff --git a/docs/PromotionTierCampaignValidityTimeframe.md b/docs/PromotionTierCampaignValidityTimeframe.md new file mode 100644 index 00000000..fb2eb0a0 --- /dev/null +++ b/docs/PromotionTierCampaignValidityTimeframe.md @@ -0,0 +1,9 @@ +# VoucherifySdk::PromotionTierCampaignValidityTimeframe + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **interval** | **String** | Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a campaign with an `interval` of `P2D` will be active every other day. | [optional] | +| **duration** | **String** | Defines the amount of time the campaign will be active in ISO 8601 format. For example, a campaign with a `duration` of `P1D` will be valid for a duration of one day. | [optional] | + diff --git a/docs/PromotionTierCreateParams.md b/docs/PromotionTierCreateParams.md new file mode 100644 index 00000000..e6d2630d --- /dev/null +++ b/docs/PromotionTierCreateParams.md @@ -0,0 +1,20 @@ +# VoucherifySdk::PromotionTierCreateParams + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Name of the promotion tier. | | +| **banner** | **String** | Text to be displayed to your customers on your website. | [optional] | +| **action** | [**PromotionTierAction**](PromotionTierAction.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. | [optional] | +| **validation_rules** | **Array<String>** | Array containing the ID of the validation rule associated with the promotion tier. | [optional] | +| **active** | **Boolean** | A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier | [optional] | +| **hierarchy** | **Integer** | The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**PromotionTierValidityTimeframe**](PromotionTierValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **category** | **String** | Assign category to the promotion tier. | [optional] | +| **category_id** | **String** | Instead of using the category name, you can alternatively assign a new category to a promotion tier using a unique category ID, i.e. `cat_0c9da30e7116ba6bba`. | [optional] | + diff --git a/docs/PromotionTierSummary.md b/docs/PromotionTierSummary.md new file mode 100644 index 00000000..b3e71156 --- /dev/null +++ b/docs/PromotionTierSummary.md @@ -0,0 +1,9 @@ +# VoucherifySdk::PromotionTierSummary + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemptions** | [**PromotionTierSummaryRedemptions**](PromotionTierSummaryRedemptions.md) | | [optional] | +| **orders** | [**PromotionTierSummaryOrders**](PromotionTierSummaryOrders.md) | | [optional] | + diff --git a/docs/PromotionTierSummaryOrders.md b/docs/PromotionTierSummaryOrders.md new file mode 100644 index 00000000..d95c6b12 --- /dev/null +++ b/docs/PromotionTierSummaryOrders.md @@ -0,0 +1,9 @@ +# VoucherifySdk::PromotionTierSummaryOrders + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total_amount** | **Integer** | Sum of order totals. | [optional] | +| **total_discount_amount** | **Integer** | Sum of total discount applied using the promotion tier. | [optional] | + diff --git a/docs/PromotionTierSummaryRedemptions.md b/docs/PromotionTierSummaryRedemptions.md new file mode 100644 index 00000000..619e910b --- /dev/null +++ b/docs/PromotionTierSummaryRedemptions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::PromotionTierSummaryRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total_redeemed** | **Integer** | Number of times the promotion tier was redeemed. | [optional] | + diff --git a/docs/PromotionTierValidityTimeframe.md b/docs/PromotionTierValidityTimeframe.md new file mode 100644 index 00000000..0e43f522 --- /dev/null +++ b/docs/PromotionTierValidityTimeframe.md @@ -0,0 +1,9 @@ +# VoucherifySdk::PromotionTierValidityTimeframe + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **interval** | **String** | Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a promotion tier with an `interval` of `P2D` will be active every other day. | [optional] | +| **duration** | **String** | Defines the amount of time the promotion tier will be active in ISO 8601 format. For example, a promotion tier with a `duration` of `P1D` will be valid for a duration of one day. | [optional] | + diff --git a/docs/PromotionTiersList.md b/docs/PromotionTiersList.md new file mode 100644 index 00000000..52bbf623 --- /dev/null +++ b/docs/PromotionTiersList.md @@ -0,0 +1,12 @@ +# VoucherifySdk::PromotionTiersList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about promotion tiers in a dictionary. | [optional][default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of promotion tier objects. | [optional][default to 'tiers'] | +| **tiers** | [**Array<PromotionTier>**](PromotionTier.md) | Contains array of promotion tier objects. | [optional] | +| **total** | **Integer** | Total number of promotion tiers. | [optional] | +| **has_more** | **Boolean** | As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. | [optional] | + diff --git a/docs/PromotionsApi.md b/docs/PromotionsApi.md new file mode 100644 index 00000000..70c8b35f --- /dev/null +++ b/docs/PromotionsApi.md @@ -0,0 +1,678 @@ +# VoucherifySdk::PromotionsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_promotion_stack**](PromotionsApi.md#create_promotion_stack) | **POST** /v1/promotions/{campaignId}/stacks | Create Promotion Stack | +| [**delete_promotion_stack**](PromotionsApi.md#delete_promotion_stack) | **DELETE** /v1/promotions/{campaignId}/stacks/{stackId} | Delete Promotion Stack | +| [**delete_promotion_tier**](PromotionsApi.md#delete_promotion_tier) | **DELETE** /v1/promotions/tiers/{promotionTierId} | Delete Promotion Tier | +| [**disable_promotion_tier**](PromotionsApi.md#disable_promotion_tier) | **POST** /v1/promotions/tiers/{promotionTierId}/disable | Disable Promotion Tier | +| [**enable_promotion_tier**](PromotionsApi.md#enable_promotion_tier) | **POST** /v1/promotions/tiers/{promotionTierId}/enable | Enable Promotion Tier | +| [**get_promotion_stack**](PromotionsApi.md#get_promotion_stack) | **GET** /v1/promotions/{campaignId}/stacks/{stackId} | Get Promotion Stack | +| [**get_promotion_tier**](PromotionsApi.md#get_promotion_tier) | **GET** /v1/promotions/tiers/{promotionTierId} | Get Promotion Tier | +| [**list_all_promotion_stacks**](PromotionsApi.md#list_all_promotion_stacks) | **GET** /v1/promotions/stacks | List Promotion Stacks | +| [**list_promotion_stacks_in_campaign**](PromotionsApi.md#list_promotion_stacks_in_campaign) | **GET** /v1/promotions/{campaignId}/stacks | List Promotion Stacks in Campaign | +| [**list_promotion_tiers_from_campaign**](PromotionsApi.md#list_promotion_tiers_from_campaign) | **GET** /v1/promotions/{campaignId}/tiers | List Promotion Tiers from Campaign | +| [**update_promotion_stack**](PromotionsApi.md#update_promotion_stack) | **PUT** /v1/promotions/{campaignId}/stacks/{stackId} | Update Promotion Stack | + + +## create_promotion_stack + +> create_promotion_stack(campaign_id, opts) + +Create Promotion Stack + +This method creates one promotion stack. The sequence of promotion tier IDs will determine the promotion stacking order. + +### 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::PromotionsApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID. +opts = { + promotions_stacks_create_request_body: VoucherifySdk::PromotionsStacksCreateRequestBody.new({name: 'name_example', tiers: VoucherifySdk::PromotionStackBaseTiers.new({ids: ['ids_example']})}) # PromotionsStacksCreateRequestBody | Specify the order of promotion tiers for the promotion stack. +} + +begin + # Create Promotion Stack + result = api_instance.create_promotion_stack(campaign_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->create_promotion_stack: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID. | | +| **promotions_stacks_create_request_body** | [**PromotionsStacksCreateRequestBody**](PromotionsStacksCreateRequestBody.md) | Specify the order of promotion tiers for the promotion stack. | [optional] | + +### Return type + +[**PromotionsStacksCreateResponseBody**](PromotionsStacksCreateResponseBody.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 + + +## delete_promotion_stack + +> delete_promotion_stack(campaign_id, stack_id) + +Delete Promotion Stack + +This method deletes a promotion stack. + +### 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::PromotionsApi.new +campaign_id = 'campaign_id_example' # String | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. +stack_id = 'stack_id_example' # String | Promotion stack ID. + +begin + # Delete Promotion Stack + api_instance.delete_promotion_stack(campaign_id, stack_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->delete_promotion_stack: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. | | +| **stack_id** | **String** | Promotion stack ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## delete_promotion_tier + +> delete_promotion_tier(promotion_tier_id) + +Delete Promotion Tier + +This method deletes a promotion tier. + +### 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::PromotionsApi.new +promotion_tier_id = 'promotion_tier_id_example' # String | Unique promotion tier ID. + +begin + # Delete Promotion Tier + api_instance.delete_promotion_tier(promotion_tier_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->delete_promotion_tier: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **promotion_tier_id** | **String** | Unique promotion tier ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## disable_promotion_tier + +> disable_promotion_tier(promotion_tier_id) + +Disable Promotion Tier + +This method disables a promotion tier, i.e. makes the active parameter false. + +### 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::PromotionsApi.new +promotion_tier_id = 'promotion_tier_id_example' # String | Unique promotion tier ID. + +begin + # Disable Promotion Tier + result = api_instance.disable_promotion_tier(promotion_tier_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->disable_promotion_tier: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **promotion_tier_id** | **String** | Unique promotion tier ID. | | + +### Return type + +[**PromotionsTiersDisableResponseBody**](PromotionsTiersDisableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## enable_promotion_tier + +> enable_promotion_tier(promotion_tier_id) + +Enable Promotion Tier + +This method enables a promotion tier, i.e. makes the active parameter true. + +### 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::PromotionsApi.new +promotion_tier_id = 'promotion_tier_id_example' # String | Unique promotion tier ID. + +begin + # Enable Promotion Tier + result = api_instance.enable_promotion_tier(promotion_tier_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->enable_promotion_tier: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **promotion_tier_id** | **String** | Unique promotion tier ID. | | + +### Return type + +[**PromotionsTiersEnableResponseBody**](PromotionsTiersEnableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_promotion_stack + +> get_promotion_stack(campaign_id, stack_id) + +Get Promotion Stack + +This method returns the details of a promotion stack, including the promotion tiers grouped within the stack. + +### 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::PromotionsApi.new +campaign_id = 'campaign_id_example' # String | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. +stack_id = 'stack_id_example' # String | Promotion stack ID. + +begin + # Get Promotion Stack + result = api_instance.get_promotion_stack(campaign_id, stack_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->get_promotion_stack: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. | | +| **stack_id** | **String** | Promotion stack ID. | | + +### Return type + +[**PromotionsStacksGetResponseBody**](PromotionsStacksGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_promotion_tier + +> get_promotion_tier(promotion_tier_id) + +Get Promotion Tier + +This method enables you to retrieve a specific promotion tier. + +### 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::PromotionsApi.new +promotion_tier_id = 'promotion_tier_id_example' # String | Unique promotion tier ID. + +begin + # Get Promotion Tier + result = api_instance.get_promotion_tier(promotion_tier_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->get_promotion_tier: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **promotion_tier_id** | **String** | Unique promotion tier ID. | | + +### Return type + +[**PromotionsTiersGetResponseBody**](PromotionsTiersGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_all_promotion_stacks + +> list_all_promotion_stacks(opts) + +List Promotion Stacks + +This method enables you to list promotion stacks irrespective of the campaign they are associated with. You can use filters in the query parameters to specify the stacks to be returned in the response. # Advanced filters for fetching promotion stacks + +### 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::PromotionsApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrderListAllPromotionStacks::CREATED_AT, # ParameterOrderListAllPromotionStacks | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + created_at: VoucherifySdk::ParameterCreatedBeforeAfter.new, # ParameterCreatedBeforeAfter | A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z + updated_at: VoucherifySdk::ParameterUpdatedBeforeAfter.new # ParameterUpdatedBeforeAfter | A filter on the list based on the object updated_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [updated_at][before] 2017-09-08T13:52:18.227Z +} + +begin + # List Promotion Stacks + result = api_instance.list_all_promotion_stacks(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->list_all_promotion_stacks: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrderListAllPromotionStacks**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **created_at** | [**ParameterCreatedBeforeAfter**](.md) | A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z | [optional] | +| **updated_at** | [**ParameterUpdatedBeforeAfter**](.md) | A filter on the list based on the object updated_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [updated_at][before] 2017-09-08T13:52:18.227Z | [optional] | + +### Return type + +[**PromotionsStacksListResponseBody**](PromotionsStacksListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_promotion_stacks_in_campaign + +> list_promotion_stacks_in_campaign(campaign_id) + +List Promotion Stacks in Campaign + +This method enables you to list promotion stacks from a specified campaign. + +### 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::PromotionsApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID. + +begin + # List Promotion Stacks in Campaign + result = api_instance.list_promotion_stacks_in_campaign(campaign_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->list_promotion_stacks_in_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID. | | + +### Return type + +[**PromotionsStacksListResponseBody**](PromotionsStacksListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_promotion_tiers_from_campaign + +> list_promotion_tiers_from_campaign(campaign_id) + +List Promotion Tiers from Campaign + +This method enables you to list promotion tiers from a specified campaign. + +### 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::PromotionsApi.new +campaign_id = 'campaign_id_example' # String | Unique campaign ID assigned by Voucherify. + +begin + # List Promotion Tiers from Campaign + result = api_instance.list_promotion_tiers_from_campaign(campaign_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->list_promotion_tiers_from_campaign: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | Unique campaign ID assigned by Voucherify. | | + +### Return type + +[**PromotionsTiersListResponseBody**](PromotionsTiersListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_promotion_stack + +> update_promotion_stack(campaign_id, stack_id, opts) + +Update Promotion Stack + +This methods allows for editing an existing stack. + +### 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::PromotionsApi.new +campaign_id = 'campaign_id_example' # String | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. +stack_id = 'stack_id_example' # String | Promotion stack ID. +opts = { + promotions_stacks_update_request_body: VoucherifySdk::PromotionsStacksUpdateRequestBody.new # PromotionsStacksUpdateRequestBody | Specify the promotion stack parameters that you would like to update. +} + +begin + # Update Promotion Stack + result = api_instance.update_promotion_stack(campaign_id, stack_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PromotionsApi->update_promotion_stack: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign_id** | **String** | ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. | | +| **stack_id** | **String** | Promotion stack ID. | | +| **promotions_stacks_update_request_body** | [**PromotionsStacksUpdateRequestBody**](PromotionsStacksUpdateRequestBody.md) | Specify the promotion stack parameters that you would like to update. | [optional] | + +### Return type + +[**PromotionsStacksUpdateResponseBody**](PromotionsStacksUpdateResponseBody.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 + diff --git a/docs/PromotionsStacksCreateRequestBody.md b/docs/PromotionsStacksCreateRequestBody.md new file mode 100644 index 00000000..8aae4395 --- /dev/null +++ b/docs/PromotionsStacksCreateRequestBody.md @@ -0,0 +1,10 @@ +# VoucherifySdk::PromotionsStacksCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Promotion stack name. | | +| **tiers** | [**PromotionStackBaseTiers**](PromotionStackBaseTiers.md) | | | +| **category_id** | **String** | Promotion stack category ID. | [optional] | + diff --git a/docs/PromotionsStacksCreateResponseBody.md b/docs/PromotionsStacksCreateResponseBody.md new file mode 100644 index 00000000..224445ff --- /dev/null +++ b/docs/PromotionsStacksCreateResponseBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::PromotionsStacksCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Promotion stack name. | | +| **tiers** | [**PromotionStackBaseTiers**](PromotionStackBaseTiers.md) | | | +| **id** | **String** | Unique promotion stack ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. | | +| **campaign_id** | **String** | Promotion stack's parent campaign's unique ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'promotion_stack'] | +| **category_id** | **String** | Promotion stack category ID. | | +| **categories** | [**Array<PromotionStackBase>**](PromotionStackBase.md) | Details about the category assigned to the promotion stack. | | + diff --git a/docs/PromotionsStacksGetResponseBody.md b/docs/PromotionsStacksGetResponseBody.md new file mode 100644 index 00000000..289ade4a --- /dev/null +++ b/docs/PromotionsStacksGetResponseBody.md @@ -0,0 +1,16 @@ +# VoucherifySdk::PromotionsStacksGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Promotion stack name. | | +| **tiers** | [**PromotionStackBaseTiers**](PromotionStackBaseTiers.md) | | | +| **id** | **String** | Unique promotion stack ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the promotion stack was updated in ISO 8601 format. | [optional] | +| **campaign_id** | **String** | Promotion stack's parent campaign's unique ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'promotion_stack'] | +| **category_id** | **String** | Promotion stack category ID. | | +| **categories** | [**Array<Category>**](Category.md) | Details about the category assigned to the promotion stack. | | + diff --git a/docs/PromotionsStacksListResponseBody.md b/docs/PromotionsStacksListResponseBody.md new file mode 100644 index 00000000..9b0b394c --- /dev/null +++ b/docs/PromotionsStacksListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::PromotionsStacksListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about promotion stacks in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of promotion stack objects. | [default to 'data'] | +| **data** | [**Array<PromotionStack>**](PromotionStack.md) | Contains array of promotion stack objects. | | +| **total** | **Integer** | Total number of promotion stacks. | | + diff --git a/docs/PromotionsStacksUpdateRequestBody.md b/docs/PromotionsStacksUpdateRequestBody.md new file mode 100644 index 00000000..55637dc0 --- /dev/null +++ b/docs/PromotionsStacksUpdateRequestBody.md @@ -0,0 +1,10 @@ +# VoucherifySdk::PromotionsStacksUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Promotion stack name. | [optional] | +| **tiers** | [**PromotionsStacksUpdateRequestBodyTiers**](PromotionsStacksUpdateRequestBodyTiers.md) | | [optional] | +| **category_id** | **String** | Promotion stack category ID. | [optional] | + diff --git a/docs/PromotionsStacksUpdateRequestBodyTiers.md b/docs/PromotionsStacksUpdateRequestBodyTiers.md new file mode 100644 index 00000000..893d5a37 --- /dev/null +++ b/docs/PromotionsStacksUpdateRequestBodyTiers.md @@ -0,0 +1,9 @@ +# VoucherifySdk::PromotionsStacksUpdateRequestBodyTiers + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **ids** | **Array<String>** | Contains the list of tiers in a pre-defined sequence. | [optional] | +| **hierarchy_mode** | **String** | Category hierarchy. | [optional][default to 'MANUAL'] | + diff --git a/docs/PromotionsStacksUpdateResponseBody.md b/docs/PromotionsStacksUpdateResponseBody.md new file mode 100644 index 00000000..662af7a6 --- /dev/null +++ b/docs/PromotionsStacksUpdateResponseBody.md @@ -0,0 +1,16 @@ +# VoucherifySdk::PromotionsStacksUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Promotion stack name. | | +| **tiers** | [**PromotionStackBaseTiers**](PromotionStackBaseTiers.md) | | | +| **id** | **String** | Unique promotion stack ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the promotion stack was updated in ISO 8601 format. | | +| **campaign_id** | **String** | Promotion stack's parent campaign's unique ID. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'promotion_stack'] | +| **category_id** | **String** | Promotion stack category ID. | | +| **categories** | [**Array<PromotionStackBase>**](PromotionStackBase.md) | Details about the category assigned to the promotion stack. | | + diff --git a/docs/PromotionsTiersDisableResponseBody.md b/docs/PromotionsTiersDisableResponseBody.md new file mode 100644 index 00000000..4a5ce620 --- /dev/null +++ b/docs/PromotionsTiersDisableResponseBody.md @@ -0,0 +1,28 @@ +# VoucherifySdk::PromotionsTiersDisableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique promotion tier ID. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. | [optional] | +| **name** | **String** | Name of the promotion tier. | [optional] | +| **banner** | **String** | Text to be displayed to your customers on your website. | [optional] | +| **action** | [**PromotionTierAction**](PromotionTierAction.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. | [optional] | +| **hierarchy** | **Integer** | The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. | [optional] | +| **promotion_id** | **String** | Promotion unique ID. | [optional] | +| **campaign** | [**PromotionTierCampaign**](PromotionTierCampaign.md) | | [optional] | +| **campaign_id** | **String** | Promotion tier's parent campaign's unique ID. | [optional] | +| **active** | **Boolean** | A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**PromotionTierValidityTimeframe**](PromotionTierValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **summary** | [**PromotionTierSummary**](PromotionTierSummary.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the promotion tier. | [optional][default to 'promotion_tier'] | +| **validation_rule_assignments** | [**ValidationRuleAssignmentsList**](ValidationRuleAssignmentsList.md) | | [optional] | +| **category_id** | **String** | Promotion tier category ID. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | | [optional] | + diff --git a/docs/PromotionsTiersEnableResponseBody.md b/docs/PromotionsTiersEnableResponseBody.md new file mode 100644 index 00000000..cdfc1388 --- /dev/null +++ b/docs/PromotionsTiersEnableResponseBody.md @@ -0,0 +1,28 @@ +# VoucherifySdk::PromotionsTiersEnableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique promotion tier ID. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. | [optional] | +| **name** | **String** | Name of the promotion tier. | [optional] | +| **banner** | **String** | Text to be displayed to your customers on your website. | [optional] | +| **action** | [**PromotionTierAction**](PromotionTierAction.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. | [optional] | +| **hierarchy** | **Integer** | The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. | [optional] | +| **promotion_id** | **String** | Promotion unique ID. | [optional] | +| **campaign** | [**PromotionTierCampaign**](PromotionTierCampaign.md) | | [optional] | +| **campaign_id** | **String** | Promotion tier's parent campaign's unique ID. | [optional] | +| **active** | **Boolean** | A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**PromotionTierValidityTimeframe**](PromotionTierValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **summary** | [**PromotionTierSummary**](PromotionTierSummary.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the promotion tier. | [optional][default to 'promotion_tier'] | +| **validation_rule_assignments** | [**ValidationRuleAssignmentsList**](ValidationRuleAssignmentsList.md) | | [optional] | +| **category_id** | **String** | Promotion tier category ID. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | | [optional] | + diff --git a/docs/PromotionsTiersGetResponseBody.md b/docs/PromotionsTiersGetResponseBody.md new file mode 100644 index 00000000..b3aee91c --- /dev/null +++ b/docs/PromotionsTiersGetResponseBody.md @@ -0,0 +1,28 @@ +# VoucherifySdk::PromotionsTiersGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique promotion tier ID. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. | [optional] | +| **name** | **String** | Name of the promotion tier. | [optional] | +| **banner** | **String** | Text to be displayed to your customers on your website. | [optional] | +| **action** | [**PromotionTierAction**](PromotionTierAction.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. | [optional] | +| **hierarchy** | **Integer** | The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. | [optional] | +| **promotion_id** | **String** | Promotion unique ID. | [optional] | +| **campaign** | [**PromotionTierCampaign**](PromotionTierCampaign.md) | | [optional] | +| **campaign_id** | **String** | Promotion tier's parent campaign's unique ID. | [optional] | +| **active** | **Boolean** | A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**PromotionTierValidityTimeframe**](PromotionTierValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **summary** | [**PromotionTierSummary**](PromotionTierSummary.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the promotion tier. | [optional][default to 'promotion_tier'] | +| **validation_rule_assignments** | [**ValidationRuleAssignmentsList**](ValidationRuleAssignmentsList.md) | | [optional] | +| **category_id** | **String** | Promotion tier category ID. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | | [optional] | + diff --git a/docs/PromotionsTiersListResponseBody.md b/docs/PromotionsTiersListResponseBody.md new file mode 100644 index 00000000..560d9fb5 --- /dev/null +++ b/docs/PromotionsTiersListResponseBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::PromotionsTiersListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about promotion tiers in a dictionary. | [optional][default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of promotion tier objects. | [optional][default to 'tiers'] | +| **tiers** | [**Array<PromotionTier>**](PromotionTier.md) | Contains array of promotion tier objects. | [optional] | +| **total** | **Integer** | Total number of promotion tiers. | [optional] | +| **has_more** | **Boolean** | As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. | [optional] | + diff --git a/docs/PropertiesForLoyaltyCampaignOptions.md b/docs/PropertiesForLoyaltyCampaignOptions.md new file mode 100644 index 00000000..dfe27fed --- /dev/null +++ b/docs/PropertiesForLoyaltyCampaignOptions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::PropertiesForLoyaltyCampaignOptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **recalculate_tiers** | **Boolean** | Determine if tiers should be recalculated or no. | [optional] | + diff --git a/docs/PublicationsApi.md b/docs/PublicationsApi.md new file mode 100644 index 00000000..1a5ca8bd --- /dev/null +++ b/docs/PublicationsApi.md @@ -0,0 +1,222 @@ +# VoucherifySdk::PublicationsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_publication**](PublicationsApi.md#create_publication) | **POST** /v1/publications | Create Publication | +| [**create_publication1**](PublicationsApi.md#create_publication1) | **GET** /v1/publications/create | Create Publication | +| [**list_publications**](PublicationsApi.md#list_publications) | **GET** /v1/publications | List Publications | + + +## create_publication + +> create_publication(opts) + +Create Publication + +This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet. 🚧 Clearly define the source of the voucher You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. 🚧 Publish multiple vouchers In case you want to publish multiple vouchers within a single publication, you need to specify the campaign name and number of vouchers you want to publish. 📘 Auto-update campaign In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. + +### 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::PublicationsApi.new +opts = { + join_once: true, # Boolean | Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. + publications_create_request_body: VoucherifySdk::CreatePublicationWithCampaign.new({customer: VoucherifySdk::Customer.new, campaign: VoucherifySdk::CreatePublicationCampaign.new({name: 'camp_dphuwqH7BOVkgh4JmpDtS32l'})}) # PublicationsCreateRequestBody | Specify the publication parameters. +} + +begin + # Create Publication + result = api_instance.create_publication(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PublicationsApi->create_publication: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **join_once** | **Boolean** | Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. | [optional] | +| **publications_create_request_body** | [**PublicationsCreateRequestBody**](PublicationsCreateRequestBody.md) | Specify the publication parameters. | [optional] | + +### Return type + +[**PublicationsCreateResponseBody**](PublicationsCreateResponseBody.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_publication1 + +> create_publication1(customer, opts) + +Create Publication + +This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet. ❗️ Limited access Access to this endpoint is limited. This endpoint is designed for specific integrations and the API keys need to be configured to access this endpoint. Navigate to the **Dashboard** → **Project Settings** → **General** → **Integration Keys** to set up a pair of API keys and use them to send the request. 🚧 Clearly define the source of the voucher You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. 🚧 Publish multiple vouchers This endpoint does not support the publishing of multiple vouchers from a single campaign. In case you want to publish multiple vouchers within a single publication, you need to use a dedicated endpoint. 📘 Auto-update campaign In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. # Example Request ❗️ Required Query param voucher OR campaign MUST be filled out. If you provide both, campaign param will be skipped. + +### 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::PublicationsApi.new +customer = VoucherifySdk::Customer.new # Customer | Contains information about the customer to whom the publication was directed. +opts = { + join_once: true, # Boolean | Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. + voucher: 'voucher_example', # String | Code of voucher being published. + campaign: VoucherifySdk::CreatePublicationCampaign.new({name: 'camp_dphuwqH7BOVkgh4JmpDtS32l'}), # CreatePublicationCampaign | Create publication with campaign. + source_id: 'source_id_example', # String | The merchant’s publication ID if it is different from the Voucherify publication ID. Its an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If source_id is provided only 1 voucher can be published per request. + metadata: { key: 3.56} # Object | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. +} + +begin + # Create Publication + result = api_instance.create_publication1(customer, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PublicationsApi->create_publication1: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**Customer**](.md) | Contains information about the customer to whom the publication was directed. | | +| **join_once** | **Boolean** | Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. | [optional] | +| **voucher** | **String** | Code of voucher being published. | [optional] | +| **campaign** | [**CreatePublicationCampaign**](.md) | Create publication with campaign. | [optional] | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. Its an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If source_id is provided only 1 voucher can be published per request. | [optional] | +| **metadata** | [**Object**](.md) | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | [optional] | + +### Return type + +[**PublicationsCreateResponseBody**](PublicationsCreateResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_publications + +> list_publications(opts) + +List Publications + +Retrieve a list of publications. To return a **particular** publication, you can use the source_id query parameter and provide the source_id of the publication you are looking for specifically. # Pagination 🚧 Important! If you want to scroll through a huge set of records, it is recommended to use the Exports API. This API will return an error page_over_limit if you reach a page above 1000. # Filter Query The filters query parameter allows for joining multiple parameters with logical operators. The syntax looks as follows: ## Operators: ## Examples + +### 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::PublicationsApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrderListPublications::ID, # ParameterOrderListPublications | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + campaign: 'campaign_example', # String | Filters by a given campaign name. + customer: 'customer_example', # String | Filters by a unique customer ID. + voucher: 'voucher_example', # String | Filters by a given voucher code. + result: VoucherifySdk::ParameterResultListPublications::SUCCESS, # ParameterResultListPublications | Filters by a publication result. + voucher_type: VoucherifySdk::ParameterVoucherTypeListPublications::DISCOUNT, # ParameterVoucherTypeListPublications | Filters by a voucher type. + is_referral_code: true, # Boolean | This filter works only for the true option. If set to true, the query returns only publications of codes from referral campaigns. + filters: 'filters_example', # String | Allows for combining the filters mentioned in the endpoint description. + source_id: 'source_id_example' # String | Using this endpoint with a particular publication source_id, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular source_id. +} + +begin + # List Publications + result = api_instance.list_publications(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling PublicationsApi->list_publications: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrderListPublications**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **campaign** | **String** | Filters by a given campaign name. | [optional] | +| **customer** | **String** | Filters by a unique customer ID. | [optional] | +| **voucher** | **String** | Filters by a given voucher code. | [optional] | +| **result** | [**ParameterResultListPublications**](.md) | Filters by a publication result. | [optional] | +| **voucher_type** | [**ParameterVoucherTypeListPublications**](.md) | Filters by a voucher type. | [optional] | +| **is_referral_code** | **Boolean** | This filter works only for the true option. If set to true, the query returns only publications of codes from referral campaigns. | [optional] | +| **filters** | **String** | Allows for combining the filters mentioned in the endpoint description. | [optional] | +| **source_id** | **String** | Using this endpoint with a particular publication source_id, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular source_id. | [optional] | + +### Return type + +[**PublicationsListResponseBody**](PublicationsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/PublicationsCreateBaseResponseBody.md b/docs/PublicationsCreateBaseResponseBody.md new file mode 100644 index 00000000..a69ef685 --- /dev/null +++ b/docs/PublicationsCreateBaseResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::PublicationsCreateBaseResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique publication ID, assigned by Voucherify. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `publication`. | [default to 'publication'] | +| **created_at** | **Time** | Timestamp representing the date and time when the publication was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the customer receiving the publication. | | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | | +| **channel** | **String** | How the publication was originated. It can be your own custom channel or an example value provided here. | [default to 'API'] | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. | | +| **result** | **String** | Status of the publication attempt. | [default to 'SUCCESS'] | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **vouchers_id** | **Array<String>** | Contains the unique internal voucher ID that was assigned by Voucherify. | | + diff --git a/docs/PublicationsCreateRequestBody.md b/docs/PublicationsCreateRequestBody.md new file mode 100644 index 00000000..911a83ad --- /dev/null +++ b/docs/PublicationsCreateRequestBody.md @@ -0,0 +1,49 @@ +# VoucherifySdk::PublicationsCreateRequestBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::PublicationsCreateRequestBody.openapi_one_of +# => +# [ +# :'CreatePublicationWithCampaign', +# :'CreatePublicationWithSpecificVoucher' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::PublicationsCreateRequestBody.build(data) +# => # + +VoucherifySdk::PublicationsCreateRequestBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `CreatePublicationWithCampaign` +- `CreatePublicationWithSpecificVoucher` +- `nil` (if no type matches) + diff --git a/docs/PublicationsCreateResponseBody.md b/docs/PublicationsCreateResponseBody.md new file mode 100644 index 00000000..4e92d30a --- /dev/null +++ b/docs/PublicationsCreateResponseBody.md @@ -0,0 +1,49 @@ +# VoucherifySdk::PublicationsCreateResponseBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::PublicationsCreateResponseBody.openapi_one_of +# => +# [ +# :'PublicationsCreateVoucherResponseBody', +# :'PublicationsCreateVouchersResponseBody' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::PublicationsCreateResponseBody.build(data) +# => # + +VoucherifySdk::PublicationsCreateResponseBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `PublicationsCreateVoucherResponseBody` +- `PublicationsCreateVouchersResponseBody` +- `nil` (if no type matches) + diff --git a/docs/PublicationsCreateVoucherResponseBody.md b/docs/PublicationsCreateVoucherResponseBody.md new file mode 100644 index 00000000..52e0f14f --- /dev/null +++ b/docs/PublicationsCreateVoucherResponseBody.md @@ -0,0 +1,19 @@ +# VoucherifySdk::PublicationsCreateVoucherResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique publication ID, assigned by Voucherify. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `publication`. | [default to 'publication'] | +| **created_at** | **Time** | Timestamp representing the date and time when the publication was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the customer receiving the publication. | | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | | +| **channel** | **String** | How the publication was originated. It can be your own custom channel or an example value provided here. | [default to 'API'] | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. | | +| **result** | **String** | Status of the publication attempt. | [default to 'SUCCESS'] | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **vouchers_id** | **Array<String>** | Contains the unique internal voucher ID that was assigned by Voucherify. | | +| **voucher** | [**Voucher**](Voucher.md) | | | + diff --git a/docs/PublicationsCreateVouchersResponseBody.md b/docs/PublicationsCreateVouchersResponseBody.md new file mode 100644 index 00000000..0496a955 --- /dev/null +++ b/docs/PublicationsCreateVouchersResponseBody.md @@ -0,0 +1,19 @@ +# VoucherifySdk::PublicationsCreateVouchersResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique publication ID, assigned by Voucherify. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `publication`. | [default to 'publication'] | +| **created_at** | **Time** | Timestamp representing the date and time when the publication was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the customer receiving the publication. | | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. | | +| **channel** | **String** | How the publication was originated. It can be your own custom channel or an example value provided here. | [default to 'API'] | +| **source_id** | **String** | The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. | | +| **result** | **String** | Status of the publication attempt. | [default to 'SUCCESS'] | +| **customer** | [**CustomerWithSummaryLoyaltyReferrals**](CustomerWithSummaryLoyaltyReferrals.md) | | | +| **vouchers_id** | **Array<String>** | Contains the unique internal voucher ID that was assigned by Voucherify. | | +| **vouchers** | **Array<String>** | Contains the unique voucher codes that was assigned by Voucherify. | | + diff --git a/docs/PublicationsListResponseBody.md b/docs/PublicationsListResponseBody.md new file mode 100644 index 00000000..72b2e50e --- /dev/null +++ b/docs/PublicationsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::PublicationsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about publications in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of publications. | [default to 'publications'] | +| **publications** | [**Array<PublicationsListResponseBodyPublicationsItem>**](PublicationsListResponseBodyPublicationsItem.md) | Contains array of publication objects, voucher object will be simplified. | | +| **total** | **Integer** | Total number of publications. | | + diff --git a/docs/PublicationsListResponseBodyPublicationsItem.md b/docs/PublicationsListResponseBodyPublicationsItem.md new file mode 100644 index 00000000..174a2e4e --- /dev/null +++ b/docs/PublicationsListResponseBodyPublicationsItem.md @@ -0,0 +1,51 @@ +# VoucherifySdk::PublicationsListResponseBodyPublicationsItem + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::PublicationsListResponseBodyPublicationsItem.openapi_one_of +# => +# [ +# :'ListPublicationsItemInvalid', +# :'ListPublicationsItemValidMultipleVouchers', +# :'ListPublicationsItemValidSingleVoucher' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::PublicationsListResponseBodyPublicationsItem.build(data) +# => # + +VoucherifySdk::PublicationsListResponseBodyPublicationsItem.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ListPublicationsItemInvalid` +- `ListPublicationsItemValidMultipleVouchers` +- `ListPublicationsItemValidSingleVoucher` +- `nil` (if no type matches) + diff --git a/docs/QualificationsApi.md b/docs/QualificationsApi.md new file mode 100644 index 00000000..aab8a9aa --- /dev/null +++ b/docs/QualificationsApi.md @@ -0,0 +1,68 @@ +# VoucherifySdk::QualificationsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**check_eligibility**](QualificationsApi.md#check_eligibility) | **POST** /v1/qualifications | Check Eligibility | + + +## check_eligibility + +> check_eligibility(opts) + +Check Eligibility + + 🚧 The Qualifications endpoint in the basic mode ignores the rules checking: - Limit of total redeemed discount amount per campaign - Limit of total redemptions count per campaign - Redemptions per customer - Redemptions per customer in a campaign Generate a list of redeemables that are applicable in the context of the customer and order. The new qualifications method is an improved version of Campaign Qualifications, Voucher Qualifications, and Promotions Validation API requests. The new qualification method introduces the following improvements: - Qualification results are returned faster - No limit on the number of returned redeemables - Introduces new qualification scenarios, not available in the previous version 👍 Scenario Guide Read our dedicated guide to learn about some use cases this endpoint can cover here. # Paging The Voucherify Qualifications API request will return to you all of the redeemables available for the customer in batches of up to 50 redeemables. To get the next batch of redeemables, you need to use the starting_after cursor. To process of paging the redeemables works in the following manner: - You send the first API request for Qualifications without the starting_after parameter. - The response will contain a parameter named has_more. If the parameters value is set to true, then more redeemables are available. - Get the value of the created_at parameter of the last returned redeemable. The value of this parameter will be used as a cursor to retrieve the next page of redeemables. - Send another API request for Qualification with the starting_after parameter set to the value taken from the created_at parameter from the last returned redeemable. - Voucherify will return the next page of redeemables. - If the has_more parameter is set to true, apply steps 3-5 to get the next page of redeemables. + +### 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::QualificationsApi.new +opts = { + qualifications_check_eligibility_request_body: VoucherifySdk::QualificationsCheckEligibilityRequestBody.new # QualificationsCheckEligibilityRequestBody | Define order and customer context. +} + +begin + # Check Eligibility + result = api_instance.check_eligibility(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling QualificationsApi->check_eligibility: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **qualifications_check_eligibility_request_body** | [**QualificationsCheckEligibilityRequestBody**](QualificationsCheckEligibilityRequestBody.md) | Define order and customer context. | [optional] | + +### Return type + +[**QualificationsCheckEligibilityResponseBody**](QualificationsCheckEligibilityResponseBody.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 + diff --git a/docs/QualificationsCheckEligibilityRequestBody.md b/docs/QualificationsCheckEligibilityRequestBody.md new file mode 100644 index 00000000..1fb6dc57 --- /dev/null +++ b/docs/QualificationsCheckEligibilityRequestBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::QualificationsCheckEligibilityRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **order** | [**Order**](Order.md) | | [optional] | +| **mode** | **String** | Defines which resources Voucherify will use. The `ADVANCED` mode is available after purchase only. | [optional] | +| **tracking_id** | **String** | Is correspondent to Customer's source_id | [optional] | +| **scenario** | **String** | Defines the scenario Voucherify should consider during the qualification process. - `ALL` - Scenario that returns all redeemables available for the customer in one API request. This scenario is used by default when no value is selected. - `CUSTOMER_WALLET` - returns vouchers applicable to the customer’s cart based on the vouchers assigned to the customer’s profile. - `AUDIENCE_ONLY` - returns all vouchers, promotion tiers, and campaigns available to the customer. Voucherify validates the rules based on the customer profile only. - `PRODUCTS` - returns all promotions available for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT` - returns all promotions available for products when a discount is defined as applicable to specific item(s). - `PROMOTION_STACKS` - returns the applicable promotion stacks. - `PRODUCTS_BY_CUSTOMER` - returns all promotions available for a customer for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT_BY_CUSTOMER` - returns all promotions available for a customer for products when a discount is defined as applicable to specific item(s). | [optional] | +| **options** | [**QualificationsOption**](QualificationsOption.md) | | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can send in the request body to check against redeemables requiring **redemption** metadata validation rules to be satisfied. The validation runs against rules that are defined through the <!-- [Create Validation Rules](https://docs.voucherify.io/reference/create-validation-rules) -->[Create Validation Rules](ref:create-validation-rules) endpoint or via the Dashboard; in the _Advanced Rule Builder_ &rarr; _Advanced_ &rarr; _Redemption metadata satisfy_ or _Basic Builder_ &rarr; _Attributes match_ &rarr; _REDEMPTION METADATA_. [Read more](https://support.voucherify.io/article/148-how-to-build-a-rule). | [optional] | + diff --git a/docs/QualificationsCheckEligibilityResponseBody.md b/docs/QualificationsCheckEligibilityResponseBody.md new file mode 100644 index 00000000..11748da3 --- /dev/null +++ b/docs/QualificationsCheckEligibilityResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::QualificationsCheckEligibilityResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables** | [**QualificationsRedeemables**](QualificationsRedeemables.md) | | [optional] | +| **tracking_id** | **String** | This identifier is generated during voucher qualification based on your internal id (e.g., email, database ID). This is a hashed customer source ID. | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **stacking_rules** | [**StackingRules**](StackingRules.md) | | [optional] | + diff --git a/docs/QualificationsFieldConditions.md b/docs/QualificationsFieldConditions.md new file mode 100644 index 00000000..f8835697 --- /dev/null +++ b/docs/QualificationsFieldConditions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::QualificationsFieldConditions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**QualificationsFiltersCondition**](QualificationsFiltersCondition.md) | | [optional] | + diff --git a/docs/QualificationsFiltersCondition.md b/docs/QualificationsFiltersCondition.md new file mode 100644 index 00000000..e4a15897 --- /dev/null +++ b/docs/QualificationsFiltersCondition.md @@ -0,0 +1,13 @@ +# VoucherifySdk::QualificationsFiltersCondition + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **is** | [**Any**](Any.md) | | [optional] | +| **is_not** | [**Any**](Any.md) | | [optional] | +| **has_value** | [**Any**](Any.md) | | [optional] | +| **is_unknown** | [**Any**](Any.md) | | [optional] | +| **_in** | [**Any**](Any.md) | | [optional] | +| **not_in** | [**Any**](Any.md) | | [optional] | + diff --git a/docs/QualificationsOption.md b/docs/QualificationsOption.md new file mode 100644 index 00000000..2720bc07 --- /dev/null +++ b/docs/QualificationsOption.md @@ -0,0 +1,12 @@ +# VoucherifySdk::QualificationsOption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | The maximum number of redeemables to be returned in the API request. The actual number of returned redeemables will be determined by the API. The default value is set to 5 | [optional] | +| **starting_after** | **Time** | Cursor used for paging. | [optional] | +| **filters** | [**QualificationsOptionFilters**](QualificationsOptionFilters.md) | | [optional] | +| **expand** | **Array<String>** | The expand array lets you configure the parameters included in the response. Depending on the strings included in the array, the response will contain different details. | **Expand Option** | **Response Body** | |:---|:---| | [\"redeemable\"] | - Returns the redeemables' metadata. | | [\"category\"] | - Returns an expanded `categories` object, showing details about the category. | | [\"validation_rules\"] | - Returns an expanded `validation_rules` object, showing details about the validation rules. | | [optional] | +| **sorting_rule** | **String** | Is used to determine the order in which data is displayed in the result array. - `DEFAULT` - Sorting descending by `created_at` - `BEST_DEAL` - Sorting descending by `total_applied_discount_amount` - `LEAST_DEAL` - Sorting ascending by `total_applied_discount_amount` | [optional] | + diff --git a/docs/QualificationsOptionFilters.md b/docs/QualificationsOptionFilters.md new file mode 100644 index 00000000..374377d2 --- /dev/null +++ b/docs/QualificationsOptionFilters.md @@ -0,0 +1,14 @@ +# VoucherifySdk::QualificationsOptionFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **junction** | [**Junction**](Junction.md) | | [optional] | +| **category_id** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **campaign_id** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **resource_id** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **resource_type** | [**QualificationsOptionFiltersResourceType**](QualificationsOptionFiltersResourceType.md) | | [optional] | +| **voucher_type** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | +| **code** | [**QualificationsFieldConditions**](QualificationsFieldConditions.md) | | [optional] | + diff --git a/docs/QualificationsOptionFiltersResourceType.md b/docs/QualificationsOptionFiltersResourceType.md new file mode 100644 index 00000000..ed312dfb --- /dev/null +++ b/docs/QualificationsOptionFiltersResourceType.md @@ -0,0 +1,8 @@ +# VoucherifySdk::QualificationsOptionFiltersResourceType + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**QualificationsOptionFiltersResourceTypeConditions**](QualificationsOptionFiltersResourceTypeConditions.md) | | [optional] | + diff --git a/docs/QualificationsOptionFiltersResourceTypeConditions.md b/docs/QualificationsOptionFiltersResourceTypeConditions.md new file mode 100644 index 00000000..e9506a9f --- /dev/null +++ b/docs/QualificationsOptionFiltersResourceTypeConditions.md @@ -0,0 +1,11 @@ +# VoucherifySdk::QualificationsOptionFiltersResourceTypeConditions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **is** | [**ResourceTypes**](ResourceTypes.md) | | [optional] | +| **is_not** | [**ResourceTypes**](ResourceTypes.md) | | [optional] | +| **_in** | [**Array<ResourceTypes>**](ResourceTypes.md) | Array of qualified redeemables. Accepts more than one value. Returns the resource types entered in the array. | [optional] | +| **not_in** | [**Array<ResourceTypes>**](ResourceTypes.md) | Array of qualified redeemables. Accepts more than one value. Returns the resource types except those entered in the array. | [optional] | + diff --git a/docs/QualificationsRedeemable.md b/docs/QualificationsRedeemable.md new file mode 100644 index 00000000..2db0724f --- /dev/null +++ b/docs/QualificationsRedeemable.md @@ -0,0 +1,23 @@ +# VoucherifySdk::QualificationsRedeemable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Id of the redeemable. | [optional] | +| **object** | **String** | Object type of the redeemable. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | +| **result** | [**RedeemableResult**](RedeemableResult.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **validation_rule_id** | **String** | A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. | [optional] | +| **applicable_to** | [**ApplicableToResultList**](ApplicableToResultList.md) | | [optional] | +| **inapplicable_to** | [**InapplicableToResultList**](InapplicableToResultList.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | List of category information. | [optional] | +| **banner** | **String** | Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. | [optional] | +| **name** | **String** | Name of the redeemable. | [optional] | +| **campaign_name** | **String** | Name of the campaign associated to the redeemable. This field is available only if object is not `campaign` | [optional] | +| **campaign_id** | **String** | Id of the campaign associated to the redeemable. This field is available only if object is not `campaign` | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | +| **redeemables** | [**Array<QualificationsRedeemableBase>**](QualificationsRedeemableBase.md) | | [optional] | + diff --git a/docs/QualificationsRedeemableBase.md b/docs/QualificationsRedeemableBase.md new file mode 100644 index 00000000..ed69dd29 --- /dev/null +++ b/docs/QualificationsRedeemableBase.md @@ -0,0 +1,22 @@ +# VoucherifySdk::QualificationsRedeemableBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Id of the redeemable. | [optional] | +| **object** | **String** | Object type of the redeemable. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | +| **result** | [**RedeemableResult**](RedeemableResult.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **validation_rule_id** | **String** | A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. | [optional] | +| **applicable_to** | [**ApplicableToResultList**](ApplicableToResultList.md) | | [optional] | +| **inapplicable_to** | [**InapplicableToResultList**](InapplicableToResultList.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | List of category information. | [optional] | +| **banner** | **String** | Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. | [optional] | +| **name** | **String** | Name of the redeemable. | [optional] | +| **campaign_name** | **String** | Name of the campaign associated to the redeemable. This field is available only if object is not `campaign` | [optional] | +| **campaign_id** | **String** | Id of the campaign associated to the redeemable. This field is available only if object is not `campaign` | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | + diff --git a/docs/QualificationsRedeemables.md b/docs/QualificationsRedeemables.md new file mode 100644 index 00000000..e40a5a49 --- /dev/null +++ b/docs/QualificationsRedeemables.md @@ -0,0 +1,13 @@ +# VoucherifySdk::QualificationsRedeemables + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. Default is `list`. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of qualified redeemables. | [default to 'data'] | +| **data** | [**Array<QualificationsRedeemable>**](QualificationsRedeemable.md) | Array of qualified redeemables. | | +| **total** | **Integer** | The number of redeemables returned in the API request. | | +| **has_more** | **Boolean** | As results are always limited, the `has_more` flag indicates whether there are more records for given parameters. This let's you know if you are able to run another request (with different options) to get more records returned in the results. | | +| **more_starting_after** | **Time** | Timestamp representing the date and time to use in starting_after cursor to get more redeemables. | [optional] | + diff --git a/docs/QualificationsStackingRules.md b/docs/QualificationsStackingRules.md new file mode 100644 index 00000000..b9eccdf6 --- /dev/null +++ b/docs/QualificationsStackingRules.md @@ -0,0 +1,12 @@ +# VoucherifySdk::QualificationsStackingRules + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables_limit** | **Integer** | Defines how many redeemables can be sent in one stacking request (note: more redeemables means more processing time!). | [default to 30] | +| **applicable_redeemables_limit** | **Integer** | Defines how many of the sent redeemables will be applied to the order. For example, a user can select 30 discounts but only 5 will be applied to the order and the remaining will be labelled as SKIPPED. | [default to 5] | +| **applicable_exclusive_redeemables_limit** | **Integer** | Defines how many redeemables with an exclusive category can be applied in one request. | [default to 1] | +| **exclusive_categories** | **Array<String>** | Lists all exclusive categories. A redeemable from a campaign with an exclusive category is the only redeemable to be redeemed when applied with redeemables from other campaigns unless these campaigns are exclusive or joint. | | +| **joint_categories** | **Array<String>** | Lists all joint categories. A campaign with a joint category is always applied regardless of the exclusivity of other campaigns. | | + diff --git a/docs/RedeemGiftCard.md b/docs/RedeemGiftCard.md new file mode 100644 index 00000000..422721a5 --- /dev/null +++ b/docs/RedeemGiftCard.md @@ -0,0 +1,10 @@ +# VoucherifySdk::RedeemGiftCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | Redeemable object type. | [default to 'voucher'] | +| **id** | **String** | Redeemable code. | | +| **gift** | [**RedeemGiftCardAllOfGift**](RedeemGiftCardAllOfGift.md) | | [optional] | + diff --git a/docs/RedeemGiftCardAllOfGift.md b/docs/RedeemGiftCardAllOfGift.md new file mode 100644 index 00000000..f7222d9e --- /dev/null +++ b/docs/RedeemGiftCardAllOfGift.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemGiftCardAllOfGift + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **credits** | **Integer** | The number of credits that the user wants to use from the gift card to fulfill the order. The value of credits cannot be higher than the current balance on the gift card. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [optional] | + diff --git a/docs/RedeemLoyaltyCard.md b/docs/RedeemLoyaltyCard.md new file mode 100644 index 00000000..6b670a93 --- /dev/null +++ b/docs/RedeemLoyaltyCard.md @@ -0,0 +1,10 @@ +# VoucherifySdk::RedeemLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | Redeemable object type. | [default to 'voucher'] | +| **id** | **String** | Redeemable code. | | +| **reward** | [**RedeemLoyaltyCardAllOfReward**](RedeemLoyaltyCardAllOfReward.md) | | [optional] | + diff --git a/docs/RedeemLoyaltyCardAllOfReward.md b/docs/RedeemLoyaltyCardAllOfReward.md new file mode 100644 index 00000000..597f7978 --- /dev/null +++ b/docs/RedeemLoyaltyCardAllOfReward.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedeemLoyaltyCardAllOfReward + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward ID assigned by Voucherify. The reward must be assigned to the campaign in order for the user to be able to use the reward. | [optional] | +| **points** | **Integer** | The number of loyalty points that the user wants to spend in order to fulfill the order using a **pay with points** reward. The number of points cannot be higher than the current balance on the loyalty card. | [optional] | + diff --git a/docs/RedeemPromotionStack.md b/docs/RedeemPromotionStack.md new file mode 100644 index 00000000..38e129fe --- /dev/null +++ b/docs/RedeemPromotionStack.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedeemPromotionStack + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | Redeemable object type. | [default to 'promotion_stack'] | +| **id** | **String** | Promotion stack unique id, such as: stack_KxSD0GahLUg9ULB6TseGfUHJ | | + diff --git a/docs/RedeemPromotionTier.md b/docs/RedeemPromotionTier.md new file mode 100644 index 00000000..0d635766 --- /dev/null +++ b/docs/RedeemPromotionTier.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedeemPromotionTier + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | Redeemable object type. | [default to 'promotion_tier'] | +| **id** | **String** | Promotion tier unique id, such as: promo_Mwy9XpA0TLctSGriM5kum0qp | | + diff --git a/docs/RedeemVoucher.md b/docs/RedeemVoucher.md new file mode 100644 index 00000000..fade8ec4 --- /dev/null +++ b/docs/RedeemVoucher.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedeemVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | Redeemable object type. | [default to 'voucher'] | +| **id** | **String** | Redeemable code. | | + diff --git a/docs/RedeemableGift.md b/docs/RedeemableGift.md new file mode 100644 index 00000000..11f8254d --- /dev/null +++ b/docs/RedeemableGift.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedeemableGift + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **balance** | **Float** | Available funds. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | [optional] | +| **credits** | **Float** | The number of credits that the user wants to use from the gift card to fulfil the order. The value of credits cannot be higher than the current balance on the gift card. If the user gives more points than he has on the gift card, the application will return an error code in response. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [optional] | + diff --git a/docs/RedeemableLoyaltyCard.md b/docs/RedeemableLoyaltyCard.md new file mode 100644 index 00000000..7e3812c0 --- /dev/null +++ b/docs/RedeemableLoyaltyCard.md @@ -0,0 +1,12 @@ +# VoucherifySdk::RedeemableLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Total points incurred over lifespan of loyalty card. | [optional] | +| **balance** | **Integer** | Points available for reward redemption. | [optional] | +| **exchange_ratio** | **Float** | The cash equivalent of the points defined in the points_ratio property. | [optional] | +| **points_ratio** | **Integer** | The number of loyalty points that will map to the predefined cash amount defined by the exchange_ratio property. | [optional] | +| **transfers** | [**Array<LoyaltiesTransferPoints>**](LoyaltiesTransferPoints.md) | | [optional] | + diff --git a/docs/RedeemableResult.md b/docs/RedeemableResult.md new file mode 100644 index 00000000..43a92271 --- /dev/null +++ b/docs/RedeemableResult.md @@ -0,0 +1,11 @@ +# VoucherifySdk::RedeemableResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**RedeemableGift**](RedeemableGift.md) | | [optional] | +| **loyalty_card** | [**RedeemableLoyaltyCard**](RedeemableLoyaltyCard.md) | | [optional] | +| **error** | [**Error**](Error.md) | | [optional] | + diff --git a/docs/RedeemableResultGiftCard.md b/docs/RedeemableResultGiftCard.md new file mode 100644 index 00000000..cb391500 --- /dev/null +++ b/docs/RedeemableResultGiftCard.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemableResultGiftCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **gift** | [**RedeemableResultGiftCardGift**](RedeemableResultGiftCardGift.md) | | [optional] | + diff --git a/docs/RedeemableResultGiftCardGift.md b/docs/RedeemableResultGiftCardGift.md new file mode 100644 index 00000000..c374b431 --- /dev/null +++ b/docs/RedeemableResultGiftCardGift.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemableResultGiftCardGift + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **credits** | **Integer** | Total number of gift card credits to be applied in the redemption expressed as the smallest currency unit (e.g. 100 cents for $1.00). | [optional] | + diff --git a/docs/RedeemableResultLoyaltyCard.md b/docs/RedeemableResultLoyaltyCard.md new file mode 100644 index 00000000..cf44c3e8 --- /dev/null +++ b/docs/RedeemableResultLoyaltyCard.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemableResultLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **loyalty_card** | [**RedeemableResultLoyaltyCardLoyaltyCard**](RedeemableResultLoyaltyCardLoyaltyCard.md) | | [optional] | + diff --git a/docs/RedeemableResultLoyaltyCardLoyaltyCard.md b/docs/RedeemableResultLoyaltyCardLoyaltyCard.md new file mode 100644 index 00000000..921179cf --- /dev/null +++ b/docs/RedeemableResultLoyaltyCardLoyaltyCard.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemableResultLoyaltyCardLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Total number of loyalty points to be applied in the redemption. | [optional] | + diff --git a/docs/RedeemableResultPromotionStack.md b/docs/RedeemableResultPromotionStack.md new file mode 100644 index 00000000..7fbaa728 --- /dev/null +++ b/docs/RedeemableResultPromotionStack.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemableResultPromotionStack + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **loyalty_card** | [**RedeemableResultLoyaltyCardLoyaltyCard**](RedeemableResultLoyaltyCardLoyaltyCard.md) | | [optional] | + diff --git a/docs/RedeemableResultPromotionTier.md b/docs/RedeemableResultPromotionTier.md new file mode 100644 index 00000000..0bafe2e0 --- /dev/null +++ b/docs/RedeemableResultPromotionTier.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemableResultPromotionTier + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **discount** | [**RedeemableResultPromotionTierDiscount**](RedeemableResultPromotionTierDiscount.md) | | [optional] | + diff --git a/docs/RedeemableResultPromotionTierDiscount.md b/docs/RedeemableResultPromotionTierDiscount.md new file mode 100644 index 00000000..3241653c --- /dev/null +++ b/docs/RedeemableResultPromotionTierDiscount.md @@ -0,0 +1,55 @@ +# VoucherifySdk::RedeemableResultPromotionTierDiscount + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RedeemableResultPromotionTierDiscount.openapi_one_of +# => +# [ +# :'DiscountAmount', +# :'DiscountFixed', +# :'DiscountPercent', +# :'DiscountUnit', +# :'DiscountUnitMultiple' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RedeemableResultPromotionTierDiscount.build(data) +# => # + +VoucherifySdk::RedeemableResultPromotionTierDiscount.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `DiscountAmount` +- `DiscountFixed` +- `DiscountPercent` +- `DiscountUnit` +- `DiscountUnitMultiple` +- `nil` (if no type matches) + diff --git a/docs/RedeemableResultVoucherCode.md b/docs/RedeemableResultVoucherCode.md new file mode 100644 index 00000000..f1051972 --- /dev/null +++ b/docs/RedeemableResultVoucherCode.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedeemableResultVoucherCode + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **discount** | [**RedeemableResultPromotionTierDiscount**](RedeemableResultPromotionTierDiscount.md) | | [optional] | + diff --git a/docs/Redemption.md b/docs/Redemption.md new file mode 100644 index 00000000..d1e02866 --- /dev/null +++ b/docs/Redemption.md @@ -0,0 +1,30 @@ +# VoucherifySdk::Redemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | | +| **object** | **String** | The type of object represented by the JSON | [default to 'redemption'] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the redeeming customer. | | +| **tracking_id** | **String** | Hashed customer source ID. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the redemption. | | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **redemption** | **String** | Unique redemption ID of the parent redemption. | | +| **result** | **String** | Redemption result. | | +| **status** | **String** | Redemption status. | | +| **related_redemptions** | [**RedemptionRelatedRedemptions**](RedemptionRelatedRedemptions.md) | | [optional] | +| **failure_code** | **String** | If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. | [optional] | +| **failure_message** | **String** | If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. | [optional] | +| **order** | [**OrderCalculatedNoCustomerData**](OrderCalculatedNoCustomerData.md) | | | +| **channel** | [**RedemptionChannel**](RedemptionChannel.md) | | | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | | +| **related_object_type** | **String** | Defines the related object. | | +| **related_object_id** | **String** | Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | | +| **voucher** | [**Voucher**](Voucher.md) | | [optional] | +| **promotion_tier** | [**PromotionTier**](PromotionTier.md) | | [optional] | +| **reward** | [**RedemptionRewardResult**](RedemptionRewardResult.md) | | [optional] | +| **gift** | [**RedemptionGift**](RedemptionGift.md) | | [optional] | +| **loyalty_card** | [**RedemptionLoyaltyCard**](RedemptionLoyaltyCard.md) | | [optional] | + diff --git a/docs/RedemptionChannel.md b/docs/RedemptionChannel.md new file mode 100644 index 00000000..42329b0e --- /dev/null +++ b/docs/RedemptionChannel.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionChannel + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **channel_id** | **String** | Unique channel ID of the user performing the redemption. This is either a user ID from a user using the Voucherify Dashboard or an X-APP-Id of a user using the API. | [optional] | +| **channel_type** | **String** | The source of the channel for the redemption. A `USER` corresponds to the Voucherify Dashboard and an `API` corresponds to the API. | [optional] | + diff --git a/docs/RedemptionGift.md b/docs/RedemptionGift.md new file mode 100644 index 00000000..bd05fa92 --- /dev/null +++ b/docs/RedemptionGift.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedemptionGift + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **amount** | **Integer** | The amount subtracted from the gift card expressed as the smallest currency unit (e.g. 100 cents for $1.00). | [optional] | + diff --git a/docs/RedemptionInternal.md b/docs/RedemptionInternal.md new file mode 100644 index 00000000..67e72692 --- /dev/null +++ b/docs/RedemptionInternal.md @@ -0,0 +1,34 @@ +# VoucherifySdk::RedemptionInternal + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | [optional] | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `redemption`. | [optional][default to 'redemption'] | +| **created_at** | **Time** | Timestamp representing the date and time when the redemption was created in ISO 8601 format. | [optional] | +| **tracking_id** | **String** | Hashed customer source ID. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the redemption. | [optional] | +| **channel_type** | **String** | The source of the channel for the redemption rollback. A `USER` corresponds to the Voucherify Dashboard and an `API` corresponds to the API. | [optional] | +| **channel_id** | **String** | Unique channel ID of the user performing the redemption. This is either a user ID from a user using the Voucherify Dashboard or an X-APP-Id of a user using the API. | [optional] | +| **failure_code** | **String** | If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. | [optional] | +| **failure_message** | **String** | If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **previous_order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **reward** | [**RedemptionRewardResult**](RedemptionRewardResult.md) | | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **reason** | **String** | System generated cause for the redemption being invalid in the context of the provided parameters. | [optional] | +| **result** | **String** | Redemption result. | [optional] | +| **status** | **String** | Redemption status. | [optional] | +| **related_redemptions** | [**RedemptionInternalRelatedRedemptions**](RedemptionInternalRelatedRedemptions.md) | | [optional] | +| **parent_redemption_id** | **String** | Unique redemption ID of the parent redemption. | [optional] | +| **redemption** | **String** | Unique redemption ID of the parent redemption. | [optional] | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **customer_id** | **String** | Unique customer ID of the redeeming customer. | [optional] | +| **related_object_type** | **String** | Defines the related object. | [optional] | +| **related_object_id** | **String** | Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | [optional] | +| **related_object_parent_id** | **String** | Unique related parent object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | [optional] | +| **campaign_name** | **String** | Campaign name | [optional] | +| **voucher** | [**Voucher**](Voucher.md) | | [optional] | +| **promotion_tier** | [**PromotionTier**](PromotionTier.md) | | [optional] | + diff --git a/docs/RedemptionInternalRelatedRedemptions.md b/docs/RedemptionInternalRelatedRedemptions.md new file mode 100644 index 00000000..ad085319 --- /dev/null +++ b/docs/RedemptionInternalRelatedRedemptions.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionInternalRelatedRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **rollbacks** | [**Array<RedemptionInternalRelatedRedemptionsRollbacksItem>**](RedemptionInternalRelatedRedemptionsRollbacksItem.md) | | [optional] | +| **redemptions** | [**Array<RedemptionInternalRelatedRedemptionsItem>**](RedemptionInternalRelatedRedemptionsItem.md) | | [optional] | + diff --git a/docs/RedemptionInternalRelatedRedemptionsItem.md b/docs/RedemptionInternalRelatedRedemptionsItem.md new file mode 100644 index 00000000..212a3591 --- /dev/null +++ b/docs/RedemptionInternalRelatedRedemptionsItem.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionInternalRelatedRedemptionsItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | [optional] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | + diff --git a/docs/RedemptionInternalRelatedRedemptionsRollbacksItem.md b/docs/RedemptionInternalRelatedRedemptionsRollbacksItem.md new file mode 100644 index 00000000..8cf5f1fc --- /dev/null +++ b/docs/RedemptionInternalRelatedRedemptionsRollbacksItem.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionInternalRelatedRedemptionsRollbacksItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique rollback redemption ID. | [optional] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | + diff --git a/docs/RedemptionLoyaltyCard.md b/docs/RedemptionLoyaltyCard.md new file mode 100644 index 00000000..ab01f2f3 --- /dev/null +++ b/docs/RedemptionLoyaltyCard.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RedemptionLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Number of points being added back to the loyalty card for the reward redemption rollback. | [optional] | + diff --git a/docs/RedemptionRelatedRedemptions.md b/docs/RedemptionRelatedRedemptions.md new file mode 100644 index 00000000..8af6d7ee --- /dev/null +++ b/docs/RedemptionRelatedRedemptions.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRelatedRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **rollbacks** | [**Array<RedemptionRelatedRedemptionsRollbacksItem>**](RedemptionRelatedRedemptionsRollbacksItem.md) | | [optional] | +| **redemptions** | [**Array<RedemptionRelatedRedemptionsItem>**](RedemptionRelatedRedemptionsItem.md) | | [optional] | + diff --git a/docs/RedemptionRelatedRedemptionsItem.md b/docs/RedemptionRelatedRedemptionsItem.md new file mode 100644 index 00000000..fb94aa2e --- /dev/null +++ b/docs/RedemptionRelatedRedemptionsItem.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRelatedRedemptionsItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | [optional] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | + diff --git a/docs/RedemptionRelatedRedemptionsRollbacksItem.md b/docs/RedemptionRelatedRedemptionsRollbacksItem.md new file mode 100644 index 00000000..32ceee3d --- /dev/null +++ b/docs/RedemptionRelatedRedemptionsRollbacksItem.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRelatedRedemptionsRollbacksItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique rollback redemption ID. | [optional] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | + diff --git a/docs/RedemptionRewardResult.md b/docs/RedemptionRewardResult.md new file mode 100644 index 00000000..51b583f2 --- /dev/null +++ b/docs/RedemptionRewardResult.md @@ -0,0 +1,20 @@ +# VoucherifySdk::RedemptionRewardResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | | +| **assignment_id** | **String** | Unique reward assignment ID assigned by Voucherify. | | +| **voucher** | [**RedemptionRewardResultVoucher**](RedemptionRewardResultVoucher.md) | | | +| **product** | [**RedemptionRewardResultProduct**](RedemptionRewardResultProduct.md) | | | +| **sku** | [**RedemptionRewardResultSku**](RedemptionRewardResultSku.md) | | | +| **loyalty_tier_id** | **String** | Unique loyalty tier ID assigned by Voucherify. | | +| **id** | **String** | Unique reward ID. | [optional] | +| **name** | **String** | Name of the reward. | [optional] | +| **object** | **String** | The type of object represented by the JSON | [optional][default to 'reward'] | +| **created_at** | **Time** | Timestamp representing the date and time when the redemption was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp in ISO 8601 format indicating when the reward was updated. | [optional] | +| **parameters** | [**RedemptionRewardResultParameters**](RedemptionRewardResultParameters.md) | | [optional] | +| **type** | **String** | Reward type. | [optional] | + diff --git a/docs/RedemptionRewardResultParameters.md b/docs/RedemptionRewardResultParameters.md new file mode 100644 index 00000000..d97171d5 --- /dev/null +++ b/docs/RedemptionRewardResultParameters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::RedemptionRewardResultParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign** | [**RedemptionRewardResultParametersCampaign**](RedemptionRewardResultParametersCampaign.md) | | [optional] | +| **product** | [**RedemptionRewardResultParametersProduct**](RedemptionRewardResultParametersProduct.md) | | [optional] | +| **coin** | [**RedemptionRewardResultParametersCoin**](RedemptionRewardResultParametersCoin.md) | | [optional] | + diff --git a/docs/RedemptionRewardResultParametersCampaign.md b/docs/RedemptionRewardResultParametersCampaign.md new file mode 100644 index 00000000..50fae226 --- /dev/null +++ b/docs/RedemptionRewardResultParametersCampaign.md @@ -0,0 +1,10 @@ +# VoucherifySdk::RedemptionRewardResultParametersCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Campaign unique ID. | [optional] | +| **balance** | **Integer** | Points available for reward redemption. | [optional] | +| **type** | **String** | Defines the type of the campaign. | [optional] | + diff --git a/docs/RedemptionRewardResultParametersCoin.md b/docs/RedemptionRewardResultParametersCoin.md new file mode 100644 index 00000000..e0bcb18f --- /dev/null +++ b/docs/RedemptionRewardResultParametersCoin.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRewardResultParametersCoin + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exchange_ratio** | **Integer** | The cash equivalent of the points defined in the `points_ratio` property. | [optional] | +| **points_ratio** | **Integer** | The number of loyalty points that will map to the predefined cash amount defined by the `exchange_ratio` property. | [optional] | + diff --git a/docs/RedemptionRewardResultParametersProduct.md b/docs/RedemptionRewardResultParametersProduct.md new file mode 100644 index 00000000..1efcae0f --- /dev/null +++ b/docs/RedemptionRewardResultParametersProduct.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRewardResultParametersProduct + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID, assigned by Voucherify. | [optional] | +| **sku_id** | **String** | A unique SKU ID assigned by Voucherify. | [optional] | + diff --git a/docs/RedemptionRewardResultProduct.md b/docs/RedemptionRewardResultProduct.md new file mode 100644 index 00000000..3169519b --- /dev/null +++ b/docs/RedemptionRewardResultProduct.md @@ -0,0 +1,18 @@ +# VoucherifySdk::RedemptionRewardResultProduct + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID assigned by Voucherify. | | +| **source_id** | **String** | Unique product source ID. | | +| **name** | **String** | Unique user-defined product name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **attributes** | **Array<String>** | A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the product was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the product was updated in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the product. | [default to 'product'] | +| **skus** | [**SkusListForProduct**](SkusListForProduct.md) | | [optional] | + diff --git a/docs/RedemptionRewardResultSku.md b/docs/RedemptionRewardResultSku.md new file mode 100644 index 00000000..967ca767 --- /dev/null +++ b/docs/RedemptionRewardResultSku.md @@ -0,0 +1,19 @@ +# VoucherifySdk::RedemptionRewardResultSku + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the SKU and is assigned by Voucherify. | | +| **source_id** | **String** | A unique SKU identifier from your inventory system. | | +| **product_id** | **String** | The parent product's unique ID. | | +| **sku** | **String** | Unique user-defined SKU name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the SKU was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the SKU was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the `SKU`. | [default to 'sku'] | + diff --git a/docs/RedemptionRewardResultVoucher.md b/docs/RedemptionRewardResultVoucher.md new file mode 100644 index 00000000..29717cf9 --- /dev/null +++ b/docs/RedemptionRewardResultVoucher.md @@ -0,0 +1,37 @@ +# VoucherifySdk::RedemptionRewardResultVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the voucher. | [optional] | +| **code** | **String** | A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. | [optional] | +| **campaign** | **String** | A unique campaign name, identifies the voucher's parent campaign. | [optional] | +| **campaign_id** | **String** | Assigned by the Voucherify API, identifies the voucher's parent campaign. | [optional] | +| **category** | **String** | Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. | [optional] | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | [optional] | +| **type** | **String** | Defines the type of the voucher. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**VoucherGift**](VoucherGift.md) | | [optional] | +| **loyalty_card** | [**VoucherLoyaltyCard**](VoucherLoyaltyCard.md) | | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**VoucherValidityTimeframe**](VoucherValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **active** | **Boolean** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **assets** | [**VoucherAssets**](VoucherAssets.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the voucher was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. | [optional] | +| **holder_id** | **String** | Unique customer ID of voucher owner. | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. Default is `voucher`. | [optional][default to 'voucher'] | +| **distributions** | **Array<Object>** | | [optional] | +| **deleted** | **Boolean** | Flag indicating whether this voucher is deleted. | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | +| **publish** | [**VoucherPublish**](VoucherPublish.md) | | [optional] | +| **redemption** | [**VoucherRedemption**](VoucherRedemption.md) | | [optional] | + diff --git a/docs/RedemptionRollback.md b/docs/RedemptionRollback.md new file mode 100644 index 00000000..2710b7ab --- /dev/null +++ b/docs/RedemptionRollback.md @@ -0,0 +1,31 @@ +# VoucherifySdk::RedemptionRollback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | | +| **object** | **String** | The type of object represented by the JSON | [default to 'redemption_rollback'] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the redeeming customer. | | +| **tracking_id** | **String** | Hashed customer source ID. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the redemption. | | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **redemption** | **String** | Unique redemption ID of the parent redemption. | | +| **reason** | **String** | System generated cause for the redemption being invalid in the context of the provided parameters. | [optional] | +| **result** | **String** | Redemption result. | | +| **status** | **String** | Redemption status. | | +| **related_redemptions** | [**RedemptionRollbackRelatedRedemptions**](RedemptionRollbackRelatedRedemptions.md) | | [optional] | +| **failure_code** | **String** | If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. | [optional] | +| **failure_message** | **String** | If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. | [optional] | +| **order** | [**OrderCalculatedNoCustomerData**](OrderCalculatedNoCustomerData.md) | | | +| **channel** | [**RedemptionChannel**](RedemptionChannel.md) | | | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | | +| **related_object_type** | **String** | Defines the related object. | | +| **related_object_id** | **String** | Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | | +| **voucher** | [**Voucher**](Voucher.md) | | [optional] | +| **promotion_tier** | [**PromotionTier**](PromotionTier.md) | | [optional] | +| **reward** | [**RedemptionRewardResult**](RedemptionRewardResult.md) | | [optional] | +| **gift** | [**RedemptionGift**](RedemptionGift.md) | | [optional] | +| **loyalty_card** | [**RedemptionLoyaltyCard**](RedemptionLoyaltyCard.md) | | [optional] | + diff --git a/docs/RedemptionRollbackRelatedRedemptions.md b/docs/RedemptionRollbackRelatedRedemptions.md new file mode 100644 index 00000000..e817c47e --- /dev/null +++ b/docs/RedemptionRollbackRelatedRedemptions.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRollbackRelatedRedemptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **rollbacks** | [**Array<RedemptionRollbackRelatedRedemptionsRollbacksItem>**](RedemptionRollbackRelatedRedemptionsRollbacksItem.md) | | [optional] | +| **redemptions** | [**Array<RedemptionRollbackRelatedRedemptionsItem>**](RedemptionRollbackRelatedRedemptionsItem.md) | | [optional] | + diff --git a/docs/RedemptionRollbackRelatedRedemptionsItem.md b/docs/RedemptionRollbackRelatedRedemptionsItem.md new file mode 100644 index 00000000..a0a26de5 --- /dev/null +++ b/docs/RedemptionRollbackRelatedRedemptionsItem.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRollbackRelatedRedemptionsItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | [optional] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | + diff --git a/docs/RedemptionRollbackRelatedRedemptionsRollbacksItem.md b/docs/RedemptionRollbackRelatedRedemptionsRollbacksItem.md new file mode 100644 index 00000000..8a092abf --- /dev/null +++ b/docs/RedemptionRollbackRelatedRedemptionsRollbacksItem.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RedemptionRollbackRelatedRedemptionsRollbacksItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique rollback redemption ID. | [optional] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | [optional] | + diff --git a/docs/RedemptionsApi.md b/docs/RedemptionsApi.md new file mode 100644 index 00000000..1fb70b17 --- /dev/null +++ b/docs/RedemptionsApi.md @@ -0,0 +1,395 @@ +# VoucherifySdk::RedemptionsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**get_redemption**](RedemptionsApi.md#get_redemption) | **GET** /v1/redemptions/{redemptionId} | Get Redemption | +| [**get_voucher_redemptions**](RedemptionsApi.md#get_voucher_redemptions) | **GET** /v1/vouchers/{code}/redemption | Get Voucher's Redemptions | +| [**list_redemptions**](RedemptionsApi.md#list_redemptions) | **GET** /v1/redemptions | List Redemptions | +| [**redeem_stacked_discounts**](RedemptionsApi.md#redeem_stacked_discounts) | **POST** /v1/redemptions | Redeem Stackable Discounts | +| [**rollback_redemption**](RedemptionsApi.md#rollback_redemption) | **POST** /v1/redemptions/{redemptionId}/rollback | Rollback Redemption | +| [**rollback_stacked_redemptions**](RedemptionsApi.md#rollback_stacked_redemptions) | **POST** /v1/redemptions/{parentRedemptionId}/rollbacks | Rollback Stackable Redemptions | + + +## get_redemption + +> get_redemption(redemption_id) + +Get Redemption + +Return a redemption or redemption rollback object. This object can either be a successfull or failed redemption or redemption rollback. + +### 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::RedemptionsApi.new +redemption_id = 'redemption_id_example' # String | ID of previously created redemption. + +begin + # Get Redemption + result = api_instance.get_redemption(redemption_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RedemptionsApi->get_redemption: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemption_id** | **String** | ID of previously created redemption. | | + +### Return type + +[**RedemptionsGetResponseBody**](RedemptionsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_voucher_redemptions + +> get_voucher_redemptions(code) + +Get Voucher's Redemptions + +Retrieve the number of times a voucher was redeemed and each of the redemption details. + +### 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::RedemptionsApi.new +code = 'code_example' # String | A **code** that identifies the voucher. + +begin + # Get Voucher's Redemptions + result = api_instance.get_voucher_redemptions(code) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RedemptionsApi->get_voucher_redemptions: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A **code** that identifies the voucher. | | + +### Return type + +[**VouchersRedemptionGetResponseBody**](VouchersRedemptionGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_redemptions + +> list_redemptions(opts) + +List Redemptions + +Returns a list of redemptions previously created. The redemptions are returned in a sorted order, with the most recent redemptions appearing first. The response returns a list of redemptions of all vouchers. # Filtering results The result can be narrowed according to specified (or default) filters, for example, you can sort redemptions by date: https://api.voucherify.io/v1/redemptions?limit 3&[created_at][before] 2017-09-08T13:52:18.227Z. A filter based on the object created_at field narrows down the results and lists redemptions done before or after a particular date time. You can use the following options: [created_at][after], [created_at][before]. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z. # Failed Redemptions A redemption may fail for various reasons. You can figure out an exact reason from the failure_code: - resource_not_found - voucher with given code does not exist - voucher_not_active - voucher is not active yet (before start date) - voucher_expired - voucher has already expired (after expiration date) - voucher_disabled - voucher has been disabled (active: false) - quantity_exceeded - vouchers redemptions limit has been exceeded - gift_amount_exceeded - gift amount has been exceeded - customer_rules_violated - customer did not match the segment - order_rules_violated - order did not match validation rules - invalid_order - order was specified incorrectly - invalid_amount - order amount was specified incorrectly - missing_amount - order amount was not specified - missing_order_items - order items were not specified - missing_customer - customer was not specified + +### 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::RedemptionsApi.new +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + result: 'result_example', # String | A filter on the list based on the redemption result. Available options are: SUCCESS, FAILURE. You can provide multiple values by repeating the param. + campaign: 'campaign_example', # String | A filter by the campaign **name** that the redemption resources originate from. + customer: 'customer_example', # String | Return redemptions performed by the customer with given id or source_id. + order: VoucherifySdk::ParameterOrderListRedemptions::CREATED_AT, # ParameterOrderListRedemptions | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + created_at: VoucherifySdk::ParameterCreatedBeforeAfter.new, # ParameterCreatedBeforeAfter | A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z + filters: VoucherifySdk::ParameterFiltersListRedemptions.new # ParameterFiltersListRedemptions | Filters for listing responses. +} + +begin + # List Redemptions + result = api_instance.list_redemptions(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RedemptionsApi->list_redemptions: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **result** | **String** | A filter on the list based on the redemption result. Available options are: SUCCESS, FAILURE. You can provide multiple values by repeating the param. | [optional] | +| **campaign** | **String** | A filter by the campaign **name** that the redemption resources originate from. | [optional] | +| **customer** | **String** | Return redemptions performed by the customer with given id or source_id. | [optional] | +| **order** | [**ParameterOrderListRedemptions**](.md) | Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **created_at** | [**ParameterCreatedBeforeAfter**](.md) | A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z | [optional] | +| **filters** | [**ParameterFiltersListRedemptions**](.md) | Filters for listing responses. | [optional] | + +### Return type + +[**RedemptionsListResponseBody**](RedemptionsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## redeem_stacked_discounts + +> redeem_stacked_discounts(opts) + +Redeem Stackable Discounts + +# How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: 📘 Rollbacks You cant roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your rollback request. 📘 Also available on client-side This method is also accessible through public keys which you can use in client-side​ apps: mobile and web browser apps. Go to the dedicated endpoint to learn more. - Use X-Client-Application-Id as the application ID header. - Use X-Client-Token as the appliction secret key header. - Use client-side base URL. - Use an origin header for your custom domain. + +### 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::RedemptionsApi.new +opts = { + redemptions_redeem_request_body: VoucherifySdk::RedemptionsRedeemRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # RedemptionsRedeemRequestBody | +} + +begin + # Redeem Stackable Discounts + result = api_instance.redeem_stacked_discounts(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RedemptionsApi->redeem_stacked_discounts: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemptions_redeem_request_body** | [**RedemptionsRedeemRequestBody**](RedemptionsRedeemRequestBody.md) | | [optional] | + +### Return type + +[**RedemptionsRedeemResponseBody**](RedemptionsRedeemResponseBody.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 + + +## rollback_redemption + +> rollback_redemption(redemption_id, opts) + +Rollback Redemption + +Your business logic may include a case when you need to undo a redemption. You can revert a redemption by calling this API endpoint. # Effect The operation - creates a rollback entry in vouchers redemption history (redemption.redemption_entries) and - gives 1 redemption back to the pool (decreases redeemed_quantity by 1). # Returned funds In case of *gift card vouchers*, this method returns funds back according to the source redemption. In case of *loyalty card vouchers*, this method returns points back according to the source redemption. + +### 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::RedemptionsApi.new +redemption_id = 'redemption_id_example' # String | The original redemption ID to be rolled back (undone). +opts = { + reason: 'reason_example', # String | Reason for the rollback. + tracking_id: 'tracking_id_example', # String | Customers source_id. + redemptions_rollback_create_request_body: VoucherifySdk::RedemptionsRollbackCreateRequestBody.new # RedemptionsRollbackCreateRequestBody | Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. +} + +begin + # Rollback Redemption + result = api_instance.rollback_redemption(redemption_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RedemptionsApi->rollback_redemption: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemption_id** | **String** | The original redemption ID to be rolled back (undone). | | +| **reason** | **String** | Reason for the rollback. | [optional] | +| **tracking_id** | **String** | Customers source_id. | [optional] | +| **redemptions_rollback_create_request_body** | [**RedemptionsRollbackCreateRequestBody**](RedemptionsRollbackCreateRequestBody.md) | Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. | [optional] | + +### Return type + +[**RedemptionsRollbackCreateResponseBody**](RedemptionsRollbackCreateResponseBody.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 + + +## rollback_stacked_redemptions + +> rollback_stacked_redemptions(parent_redemption_id, opts) + +Rollback Stackable Redemptions + +Rollback a stackable redemption. When you rollback a stacked redemption, all child redemptions will be rolled back. Provide the parent redemption ID as the path parameter. + +### 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::RedemptionsApi.new +parent_redemption_id = 'parent_redemption_id_example' # String | Unique identifier of a parent redemption, e.g. r_JQfm73zWSJFQxs3bGxweYjgm. +opts = { + reason: 'reason_example', # String | Reason for the rollback. + tracking_id: 'tracking_id_example', # String | Customers source_id. + redemptions_rollbacks_create_request_body: VoucherifySdk::RedemptionsRollbacksCreateRequestBody.new # RedemptionsRollbacksCreateRequestBody | Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. +} + +begin + # Rollback Stackable Redemptions + result = api_instance.rollback_stacked_redemptions(parent_redemption_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RedemptionsApi->rollback_stacked_redemptions: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **parent_redemption_id** | **String** | Unique identifier of a parent redemption, e.g. r_JQfm73zWSJFQxs3bGxweYjgm. | | +| **reason** | **String** | Reason for the rollback. | [optional] | +| **tracking_id** | **String** | Customers source_id. | [optional] | +| **redemptions_rollbacks_create_request_body** | [**RedemptionsRollbacksCreateRequestBody**](RedemptionsRollbacksCreateRequestBody.md) | Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. | [optional] | + +### Return type + +[**RedemptionsRollbacksCreateResponseBody**](RedemptionsRollbacksCreateResponseBody.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 + diff --git a/docs/RedemptionsGetResponseBody.md b/docs/RedemptionsGetResponseBody.md new file mode 100644 index 00000000..1313090a --- /dev/null +++ b/docs/RedemptionsGetResponseBody.md @@ -0,0 +1,49 @@ +# VoucherifySdk::RedemptionsGetResponseBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RedemptionsGetResponseBody.openapi_one_of +# => +# [ +# :'Redemption', +# :'RedemptionRollback' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RedemptionsGetResponseBody.build(data) +# => # + +VoucherifySdk::RedemptionsGetResponseBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `Redemption` +- `RedemptionRollback` +- `nil` (if no type matches) + diff --git a/docs/RedemptionsListResponseBody.md b/docs/RedemptionsListResponseBody.md new file mode 100644 index 00000000..bf64937c --- /dev/null +++ b/docs/RedemptionsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::RedemptionsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about redemptions in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of redemption objects. | [default to 'redemptions'] | +| **redemptions** | [**Array<RedemptionsListResponseBodyRedemptionsItem>**](RedemptionsListResponseBodyRedemptionsItem.md) | | | +| **total** | **Integer** | Total number of redemptions. | | + diff --git a/docs/RedemptionsListResponseBodyRedemptionsItem.md b/docs/RedemptionsListResponseBodyRedemptionsItem.md new file mode 100644 index 00000000..2ad50530 --- /dev/null +++ b/docs/RedemptionsListResponseBodyRedemptionsItem.md @@ -0,0 +1,49 @@ +# VoucherifySdk::RedemptionsListResponseBodyRedemptionsItem + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RedemptionsListResponseBodyRedemptionsItem.openapi_one_of +# => +# [ +# :'Redemption', +# :'RedemptionRollback' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RedemptionsListResponseBodyRedemptionsItem.build(data) +# => # + +VoucherifySdk::RedemptionsListResponseBodyRedemptionsItem.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `Redemption` +- `RedemptionRollback` +- `nil` (if no type matches) + diff --git a/docs/RedemptionsRedeemRequestBody.md b/docs/RedemptionsRedeemRequestBody.md new file mode 100644 index 00000000..00454317 --- /dev/null +++ b/docs/RedemptionsRedeemRequestBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::RedemptionsRedeemRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables** | [**Array<StackableValidateRedeemBaseRedeemablesItem>**](StackableValidateRedeemBaseRedeemablesItem.md) | An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. | | +| **order** | [**Order**](Order.md) | | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | +| **tracking_id** | **String** | Is correspondent to Customer's source_id | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. | [optional] | +| **options** | [**ClientRedemptionsRedeemRequestBodyAllOfOptions**](ClientRedemptionsRedeemRequestBodyAllOfOptions.md) | | [optional] | + diff --git a/docs/RedemptionsRedeemResponseBody.md b/docs/RedemptionsRedeemResponseBody.md new file mode 100644 index 00000000..e80d054d --- /dev/null +++ b/docs/RedemptionsRedeemResponseBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::RedemptionsRedeemResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemptions** | [**Array<Redemption>**](Redemption.md) | | [optional] | +| **parent_redemption** | [**Redemption**](Redemption.md) | | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **inapplicable_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each inapplicable redeemable. | [optional] | +| **skipped_redeemables** | [**Array<ValidationsRedeemableSkipped>**](ValidationsRedeemableSkipped.md) | Lists validation results of each redeemable. If a redeemable can be applied, the API returns `\"status\": \"APPLICABLE\"`. | [optional] | + diff --git a/docs/RedemptionsRollbackCreateRequestBody.md b/docs/RedemptionsRollbackCreateRequestBody.md new file mode 100644 index 00000000..ebef1f27 --- /dev/null +++ b/docs/RedemptionsRollbackCreateRequestBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::RedemptionsRollbackCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reason** | **String** | Reason for the rollback. | [optional] | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **order** | [**Order**](Order.md) | | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can send in the request body to update **redemption** metadata. | [optional] | + diff --git a/docs/RedemptionsRollbackCreateResponseBody.md b/docs/RedemptionsRollbackCreateResponseBody.md new file mode 100644 index 00000000..895345bb --- /dev/null +++ b/docs/RedemptionsRollbackCreateResponseBody.md @@ -0,0 +1,31 @@ +# VoucherifySdk::RedemptionsRollbackCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | | +| **object** | **String** | The type of object represented by the JSON | [default to 'redemption_rollback'] | +| **date** | **Time** | Timestamp representing the date and time when the object was created in ISO 8601 format. | | +| **customer_id** | **String** | Unique customer ID of the redeeming customer. | | +| **tracking_id** | **String** | Hashed customer source ID. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the redemption. | | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **redemption** | **String** | Unique redemption ID of the parent redemption. | | +| **reason** | **String** | System generated cause for the redemption being invalid in the context of the provided parameters. | [optional] | +| **result** | **String** | Redemption result. | | +| **status** | **String** | Redemption status. | | +| **related_redemptions** | [**RedemptionRollbackRelatedRedemptions**](RedemptionRollbackRelatedRedemptions.md) | | [optional] | +| **failure_code** | **String** | If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. | [optional] | +| **failure_message** | **String** | If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. | [optional] | +| **order** | [**OrderCalculatedNoCustomerData**](OrderCalculatedNoCustomerData.md) | | | +| **channel** | [**RedemptionChannel**](RedemptionChannel.md) | | | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | | +| **related_object_type** | **String** | Defines the related object. | | +| **related_object_id** | **String** | Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. | | +| **voucher** | [**Voucher**](Voucher.md) | | [optional] | +| **promotion_tier** | [**PromotionTier**](PromotionTier.md) | | [optional] | +| **reward** | [**RedemptionRewardResult**](RedemptionRewardResult.md) | | [optional] | +| **gift** | [**RedemptionGift**](RedemptionGift.md) | | [optional] | +| **loyalty_card** | [**RedemptionLoyaltyCard**](RedemptionLoyaltyCard.md) | | [optional] | + diff --git a/docs/RedemptionsRollbacksCreateRequestBody.md b/docs/RedemptionsRollbacksCreateRequestBody.md new file mode 100644 index 00000000..da6e3140 --- /dev/null +++ b/docs/RedemptionsRollbacksCreateRequestBody.md @@ -0,0 +1,12 @@ +# VoucherifySdk::RedemptionsRollbacksCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reason** | **String** | Reason for the rollback. | [optional] | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **order** | [**Order**](Order.md) | | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can send in the request body to update **redemption** metadata. | [optional] | + diff --git a/docs/RedemptionsRollbacksCreateResponseBody.md b/docs/RedemptionsRollbacksCreateResponseBody.md new file mode 100644 index 00000000..f8a63ea2 --- /dev/null +++ b/docs/RedemptionsRollbacksCreateResponseBody.md @@ -0,0 +1,10 @@ +# VoucherifySdk::RedemptionsRollbacksCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **rollbacks** | [**Array<RedemptionRollback>**](RedemptionRollback.md) | Contains the rollback redemption objects of the particular incentives. | [optional] | +| **parent_rollback** | [**RedemptionRollback**](RedemptionRollback.md) | | [optional] | +| **order** | [**OrderCalculatedNoCustomerData**](OrderCalculatedNoCustomerData.md) | | [optional] | + diff --git a/docs/ReferralCampaignVoucher.md b/docs/ReferralCampaignVoucher.md new file mode 100644 index 00000000..de81358d --- /dev/null +++ b/docs/ReferralCampaignVoucher.md @@ -0,0 +1,12 @@ +# VoucherifySdk::ReferralCampaignVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | Type of voucher. | [default to 'DISCOUNT_VOUCHER'] | +| **discount** | [**Discount**](Discount.md) | | | +| **code_config** | [**CodeConfig**](CodeConfig.md) | | [optional] | +| **redemption** | [**CampaignLoyaltyVoucherRedemption**](CampaignLoyaltyVoucherRedemption.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | | + diff --git a/docs/ReferralProgram.md b/docs/ReferralProgram.md new file mode 100644 index 00000000..4b4a6950 --- /dev/null +++ b/docs/ReferralProgram.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ReferralProgram + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conversion_event_type** | **String** | Define how a referral is triggered. | [optional] | +| **custom_event** | [**ReferralProgramCustomEvent**](ReferralProgramCustomEvent.md) | | [optional] | +| **referee_reward** | [**ReferralProgramRefereeReward**](ReferralProgramRefereeReward.md) | | [optional] | + diff --git a/docs/ReferralProgramCustomEvent.md b/docs/ReferralProgramCustomEvent.md new file mode 100644 index 00000000..e0dfee95 --- /dev/null +++ b/docs/ReferralProgramCustomEvent.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ReferralProgramCustomEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique custom event ID. | [optional] | +| **name** | **String** | Custom event name. | [optional] | + diff --git a/docs/ReferralProgramRefereeReward.md b/docs/ReferralProgramRefereeReward.md new file mode 100644 index 00000000..bd3beff9 --- /dev/null +++ b/docs/ReferralProgramRefereeReward.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ReferralProgramRefereeReward + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **related_object_parent** | [**ReferralProgramRefereeRewardRelatedObjectParent**](ReferralProgramRefereeRewardRelatedObjectParent.md) | | [optional] | +| **type** | **String** | Type of reward. | [optional] | +| **amount** | **String** | Define the number of `points` to add to a loyalty card or `credits` to the balance on a gift card. In case of the gift card, the value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | [optional] | + diff --git a/docs/ReferralProgramRefereeRewardRelatedObjectParent.md b/docs/ReferralProgramRefereeRewardRelatedObjectParent.md new file mode 100644 index 00000000..7026ecc3 --- /dev/null +++ b/docs/ReferralProgramRefereeRewardRelatedObjectParent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ReferralProgramRefereeRewardRelatedObjectParent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID of the reward source. | [optional] | +| **name** | **String** | Name of the reward source. | [optional] | +| **object** | **String** | Type of resource represented by the source of the reward. | [optional][default to 'CAMPAIGN'] | + diff --git a/docs/Referrer.md b/docs/Referrer.md new file mode 100644 index 00000000..49ad22bf --- /dev/null +++ b/docs/Referrer.md @@ -0,0 +1,17 @@ +# VoucherifySdk::Referrer + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The ID of an existing customer. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/ReferrerId.md b/docs/ReferrerId.md new file mode 100644 index 00000000..f9236e7e --- /dev/null +++ b/docs/ReferrerId.md @@ -0,0 +1,9 @@ +# VoucherifySdk::ReferrerId + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier of an existing customer. | | +| **object** | **String** | The type of object represented by JSON. | [default to 'customer'] | + diff --git a/docs/ReferrerWithSummaryLoyaltyReferrals.md b/docs/ReferrerWithSummaryLoyaltyReferrals.md new file mode 100644 index 00000000..4b456e9f --- /dev/null +++ b/docs/ReferrerWithSummaryLoyaltyReferrals.md @@ -0,0 +1,25 @@ +# VoucherifySdk::ReferrerWithSummaryLoyaltyReferrals + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The ID of an existing customer that will be linked to redemption in this request. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **summary** | [**CustomerSummary**](CustomerSummary.md) | | | +| **loyalty** | [**CustomerLoyalty**](CustomerLoyalty.md) | | | +| **referrals** | [**CustomerReferrals**](CustomerReferrals.md) | | | +| **system_metadata** | **Object** | Object used to store system metadata information. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the customer was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the customer was updated in ISO 8601 format. | [optional] | +| **assets** | [**CustomerResponseDataAssets**](CustomerResponseDataAssets.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'customer'] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a customer object. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **phone** | **String** | Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. | [optional] | +| **birthday** | **Date** | *Deprecated* Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **birthdate** | **Date** | Customer's birthdate; format YYYY-MM-DD. | [optional] | +| **address** | [**CustomerBaseAddress**](CustomerBaseAddress.md) | | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | + diff --git a/docs/ResourceTypes.md b/docs/ResourceTypes.md new file mode 100644 index 00000000..33ad67f4 --- /dev/null +++ b/docs/ResourceTypes.md @@ -0,0 +1,7 @@ +# VoucherifySdk::ResourceTypes + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + diff --git a/docs/Reward.md b/docs/Reward.md new file mode 100644 index 00000000..5e7764a6 --- /dev/null +++ b/docs/Reward.md @@ -0,0 +1,18 @@ +# VoucherifySdk::Reward + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward ID, assigned by Voucherify. | | +| **name** | **String** | Reward name. | | +| **stock** | **Integer** | Configurable for **material rewards**. The number of units of the product that you want to share as reward. | | +| **redeemed** | **Integer** | Defines the number of already invoked (successful) reward redemptions. | | +| **attributes** | [**RewardAttributes**](RewardAttributes.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the reward. A set of key/value pairs that you can attach to a reward object. It can be useful for storing additional information about the reward in a structured format. | | +| **type** | **String** | Reward type. | | +| **parameters** | [**RewardType**](RewardType.md) | | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the reward was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward. | [default to 'reward'] | + diff --git a/docs/RewardAssignment.md b/docs/RewardAssignment.md new file mode 100644 index 00000000..87aac727 --- /dev/null +++ b/docs/RewardAssignment.md @@ -0,0 +1,15 @@ +# VoucherifySdk::RewardAssignment + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward assignment ID, assigned by Voucherify. | | +| **reward_id** | **String** | Associated reward ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward assignment. | [default to 'reward_assignment'] | +| **related_object_id** | **String** | Related object ID to which the reward was assigned. | | +| **related_object_type** | **String** | Related object type to which the reward was assigned. | [default to 'campaign'] | +| **parameters** | [**RewardAssignmentParametersParameters**](RewardAssignmentParametersParameters.md) | | [optional] | + diff --git a/docs/RewardAssignmentBase.md b/docs/RewardAssignmentBase.md new file mode 100644 index 00000000..1e21f8c7 --- /dev/null +++ b/docs/RewardAssignmentBase.md @@ -0,0 +1,14 @@ +# VoucherifySdk::RewardAssignmentBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward assignment ID, assigned by Voucherify. | | +| **reward_id** | **String** | Associated reward ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward assignment. | [default to 'reward_assignment'] | +| **related_object_id** | **String** | Related object ID to which the reward was assigned. | | +| **related_object_type** | **String** | Related object type to which the reward was assigned. | [default to 'campaign'] | + diff --git a/docs/RewardAssignmentParameters.md b/docs/RewardAssignmentParameters.md new file mode 100644 index 00000000..86247ea3 --- /dev/null +++ b/docs/RewardAssignmentParameters.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardAssignmentParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **parameters** | [**RewardAssignmentParametersParameters**](RewardAssignmentParametersParameters.md) | | [optional] | + diff --git a/docs/RewardAssignmentParametersParameters.md b/docs/RewardAssignmentParametersParameters.md new file mode 100644 index 00000000..f10a11b1 --- /dev/null +++ b/docs/RewardAssignmentParametersParameters.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardAssignmentParametersParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **loyalty** | [**RewardAssignmentParametersParametersLoyalty**](RewardAssignmentParametersParametersLoyalty.md) | | | + diff --git a/docs/RewardAssignmentParametersParametersLoyalty.md b/docs/RewardAssignmentParametersParametersLoyalty.md new file mode 100644 index 00000000..82e306ca --- /dev/null +++ b/docs/RewardAssignmentParametersParametersLoyalty.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardAssignmentParametersParametersLoyalty + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | The number of points required to redeem the reward. | [optional] | + diff --git a/docs/RewardAssignmentsCreateCoinRewardRequestBody.md b/docs/RewardAssignmentsCreateCoinRewardRequestBody.md new file mode 100644 index 00000000..5dc89207 --- /dev/null +++ b/docs/RewardAssignmentsCreateCoinRewardRequestBody.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RewardAssignmentsCreateCoinRewardRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign** | **String** | The campaign ID of the campaign to which the reward is to be assigned. | | +| **validation_rules** | **Array<String>** | | [optional] | + diff --git a/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody.md b/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody.md new file mode 100644 index 00000000..f5ce1df8 --- /dev/null +++ b/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign** | **String** | The campaign ID of the campaign to which the reward is to be assigned. | | +| **parameters** | [**RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters**](RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters.md) | | | + diff --git a/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters.md b/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters.md new file mode 100644 index 00000000..b2670ea6 --- /dev/null +++ b/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **loyalty** | [**RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty**](RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty.md) | | | + diff --git a/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty.md b/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty.md new file mode 100644 index 00000000..f2cb0843 --- /dev/null +++ b/docs/RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Number of points that will be subtracted from the loyalty card points balance if the reward is redeemed. | [optional] | + diff --git a/docs/RewardAttributes.md b/docs/RewardAttributes.md new file mode 100644 index 00000000..4fc089da --- /dev/null +++ b/docs/RewardAttributes.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RewardAttributes + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file. | [optional] | +| **description** | **String** | An arbitrary string that you can attach to a material reward. | [optional] | + diff --git a/docs/RewardType.md b/docs/RewardType.md new file mode 100644 index 00000000..7331b505 --- /dev/null +++ b/docs/RewardType.md @@ -0,0 +1,51 @@ +# VoucherifySdk::RewardType + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RewardType.openapi_one_of +# => +# [ +# :'RewardTypeCampaign', +# :'RewardTypeCoin', +# :'RewardTypeMaterial' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RewardType.build(data) +# => # + +VoucherifySdk::RewardType.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `RewardTypeCampaign` +- `RewardTypeCoin` +- `RewardTypeMaterial` +- `nil` (if no type matches) + diff --git a/docs/RewardTypeCampaign.md b/docs/RewardTypeCampaign.md new file mode 100644 index 00000000..fa960e6d --- /dev/null +++ b/docs/RewardTypeCampaign.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardTypeCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **campaign** | [**RewardTypeCampaignCampaign**](RewardTypeCampaignCampaign.md) | | | + diff --git a/docs/RewardTypeCampaignCampaign.md b/docs/RewardTypeCampaignCampaign.md new file mode 100644 index 00000000..ac099530 --- /dev/null +++ b/docs/RewardTypeCampaignCampaign.md @@ -0,0 +1,10 @@ +# VoucherifySdk::RewardTypeCampaignCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID, assigned by Voucherify. | | +| **balance** | **Integer** | The incremental amout to be added to the current balance on the gift card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | [optional] | +| **type** | **String** | Campaign type. | | + diff --git a/docs/RewardTypeCoin.md b/docs/RewardTypeCoin.md new file mode 100644 index 00000000..3c36692d --- /dev/null +++ b/docs/RewardTypeCoin.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardTypeCoin + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **coin** | [**RewardTypeCoinCoin**](RewardTypeCoinCoin.md) | | | + diff --git a/docs/RewardTypeCoinCoin.md b/docs/RewardTypeCoinCoin.md new file mode 100644 index 00000000..44f090f2 --- /dev/null +++ b/docs/RewardTypeCoinCoin.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RewardTypeCoinCoin + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **exchange_ratio** | **Float** | The cash equivalent of the points defined in the points_ratio property. | | +| **points_ratio** | **Integer** | The number of loyalty points that will map to the predefined cash amount defined by the exchange_ratio property. | [optional] | + diff --git a/docs/RewardTypeMaterial.md b/docs/RewardTypeMaterial.md new file mode 100644 index 00000000..0b48e5eb --- /dev/null +++ b/docs/RewardTypeMaterial.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardTypeMaterial + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **product** | [**RewardTypeMaterialProduct**](RewardTypeMaterialProduct.md) | | | + diff --git a/docs/RewardTypeMaterialProduct.md b/docs/RewardTypeMaterialProduct.md new file mode 100644 index 00000000..189e9e3e --- /dev/null +++ b/docs/RewardTypeMaterialProduct.md @@ -0,0 +1,9 @@ +# VoucherifySdk::RewardTypeMaterialProduct + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID, assigned by Voucherify. | | +| **sku_id** | **String** | Unique SKU ID, assigned by Voucherify, of the SKU given as a reward. | | + diff --git a/docs/RewardsApi.md b/docs/RewardsApi.md new file mode 100644 index 00000000..90b6b155 --- /dev/null +++ b/docs/RewardsApi.md @@ -0,0 +1,379 @@ +# VoucherifySdk::RewardsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_reward_assignment**](RewardsApi.md#create_reward_assignment) | **POST** /v1/rewards/{rewardId}/assignments | Create Reward Assignment | +| [**delete_reward**](RewardsApi.md#delete_reward) | **DELETE** /v1/rewards/{rewardId} | Delete Reward | +| [**delete_reward_assignment**](RewardsApi.md#delete_reward_assignment) | **DELETE** /v1/rewards/{rewardId}/assignments/{assignmentId} | Delete Reward Assignment | +| [**get_reward_assignment**](RewardsApi.md#get_reward_assignment) | **GET** /v1/rewards/{rewardId}/assignments/{assignmentId} | Get Reward Assignment | +| [**list_reward_assignments**](RewardsApi.md#list_reward_assignments) | **GET** /v1/rewards/{rewardId}/assignments | List Reward Assignments | +| [**update_reward_assignment**](RewardsApi.md#update_reward_assignment) | **PUT** /v1/rewards/{rewardId}/assignments/{assignmentId} | Update Reward Assignment | + + +## create_reward_assignment + +> create_reward_assignment(reward_id, opts) + +Create Reward Assignment + +Assigns a reward to a specified loyalty campaign. + +### 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::RewardsApi.new +reward_id = 'reward_id_example' # String | A unique reward ID. +opts = { + rewards_assignments_create_request_body: VoucherifySdk::RewardAssignmentsCreateCoinRewardRequestBody.new({campaign: 'campaign_example'}) # RewardsAssignmentsCreateRequestBody | Provide the campaign ID of the campaign to which the reward is to be assigned and define the cost of the reward in terms of loyalty points. +} + +begin + # Create Reward Assignment + result = api_instance.create_reward_assignment(reward_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RewardsApi->create_reward_assignment: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward_id** | **String** | A unique reward ID. | | +| **rewards_assignments_create_request_body** | [**RewardsAssignmentsCreateRequestBody**](RewardsAssignmentsCreateRequestBody.md) | Provide the campaign ID of the campaign to which the reward is to be assigned and define the cost of the reward in terms of loyalty points. | [optional] | + +### Return type + +[**RewardsAssignmentsCreateResponseBody**](RewardsAssignmentsCreateResponseBody.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 + + +## delete_reward + +> delete_reward(reward_id) + +Delete Reward + +Delete a reward. + +### 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::RewardsApi.new +reward_id = 'reward_id_example' # String | A unique reward ID. + +begin + # Delete Reward + api_instance.delete_reward(reward_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling RewardsApi->delete_reward: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward_id** | **String** | A unique reward ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## delete_reward_assignment + +> delete_reward_assignment(reward_id, assignment_id) + +Delete Reward Assignment + +This method deletes a reward assignment for a particular reward. + +### 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::RewardsApi.new +reward_id = 'reward_id_example' # String | A unique reward ID. +assignment_id = 'assignment_id_example' # String | A unique reward assignment ID. + +begin + # Delete Reward Assignment + api_instance.delete_reward_assignment(reward_id, assignment_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling RewardsApi->delete_reward_assignment: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward_id** | **String** | A unique reward ID. | | +| **assignment_id** | **String** | A unique reward assignment ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## get_reward_assignment + +> get_reward_assignment(reward_id, assignment_id) + +Get Reward Assignment + +Retrieve a reward assignment. + +### 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::RewardsApi.new +reward_id = 'reward_id_example' # String | A unique reward ID. +assignment_id = 'assignment_id_example' # String | A unique reward assignment ID. + +begin + # Get Reward Assignment + result = api_instance.get_reward_assignment(reward_id, assignment_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RewardsApi->get_reward_assignment: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward_id** | **String** | A unique reward ID. | | +| **assignment_id** | **String** | A unique reward assignment ID. | | + +### Return type + +[**RewardsAssignmentsGetResponseBody**](RewardsAssignmentsGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_reward_assignments + +> list_reward_assignments(reward_id, opts) + +List Reward Assignments + +Retrieve reward assignments by the reward ID. + +### 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::RewardsApi.new +reward_id = 'reward_id_example' # String | A unique reward ID. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56 # Integer | Which page of results to return. +} + +begin + # List Reward Assignments + result = api_instance.list_reward_assignments(reward_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RewardsApi->list_reward_assignments: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward_id** | **String** | A unique reward ID. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | + +### Return type + +[**RewardsAssignmentsListResponseBody**](RewardsAssignmentsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_reward_assignment + +> update_reward_assignment(reward_id, assignment_id, opts) + +Update Reward Assignment + +Update the number of points needed to successfully redeem the reward. + +### 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::RewardsApi.new +reward_id = 'reward_id_example' # String | A unique reward ID. +assignment_id = 'assignment_id_example' # String | A unique reward assignment ID. +opts = { + rewards_assignments_update_request_body: VoucherifySdk::RewardsAssignmentsUpdateRequestBody.new # RewardsAssignmentsUpdateRequestBody | Define the number of points required to exchange for the reward. +} + +begin + # Update Reward Assignment + result = api_instance.update_reward_assignment(reward_id, assignment_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling RewardsApi->update_reward_assignment: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reward_id** | **String** | A unique reward ID. | | +| **assignment_id** | **String** | A unique reward assignment ID. | | +| **rewards_assignments_update_request_body** | [**RewardsAssignmentsUpdateRequestBody**](RewardsAssignmentsUpdateRequestBody.md) | Define the number of points required to exchange for the reward. | [optional] | + +### Return type + +[**RewardsAssignmentsUpdateResponseBody**](RewardsAssignmentsUpdateResponseBody.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 + diff --git a/docs/RewardsAssignmentsCreateRequestBody.md b/docs/RewardsAssignmentsCreateRequestBody.md new file mode 100644 index 00000000..f8a5d853 --- /dev/null +++ b/docs/RewardsAssignmentsCreateRequestBody.md @@ -0,0 +1,49 @@ +# VoucherifySdk::RewardsAssignmentsCreateRequestBody + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RewardsAssignmentsCreateRequestBody.openapi_one_of +# => +# [ +# :'RewardAssignmentsCreateCoinRewardRequestBody', +# :'RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::RewardsAssignmentsCreateRequestBody.build(data) +# => # + +VoucherifySdk::RewardsAssignmentsCreateRequestBody.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `RewardAssignmentsCreateCoinRewardRequestBody` +- `RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody` +- `nil` (if no type matches) + diff --git a/docs/RewardsAssignmentsCreateResponseBody.md b/docs/RewardsAssignmentsCreateResponseBody.md new file mode 100644 index 00000000..7dbe8ec9 --- /dev/null +++ b/docs/RewardsAssignmentsCreateResponseBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::RewardsAssignmentsCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward assignment ID, assigned by Voucherify. | | +| **reward_id** | **String** | Associated reward ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward assignment. | [default to 'reward_assignment'] | +| **related_object_id** | **String** | Related object ID to which the reward was assigned. | | +| **related_object_type** | **String** | Related object type to which the reward was assigned. | [default to 'campaign'] | +| **parameters** | [**RewardAssignmentParametersParameters**](RewardAssignmentParametersParameters.md) | | [optional] | + diff --git a/docs/RewardsAssignmentsGetResponseBody.md b/docs/RewardsAssignmentsGetResponseBody.md new file mode 100644 index 00000000..0ba67df1 --- /dev/null +++ b/docs/RewardsAssignmentsGetResponseBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::RewardsAssignmentsGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward assignment ID, assigned by Voucherify. | | +| **reward_id** | **String** | Associated reward ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward assignment. | [default to 'reward_assignment'] | +| **related_object_id** | **String** | Related object ID to which the reward was assigned. | | +| **related_object_type** | **String** | Related object type to which the reward was assigned. | [default to 'campaign'] | +| **parameters** | [**RewardAssignmentParametersParameters**](RewardAssignmentParametersParameters.md) | | [optional] | + diff --git a/docs/RewardsAssignmentsListResponseBody.md b/docs/RewardsAssignmentsListResponseBody.md new file mode 100644 index 00000000..9adaa975 --- /dev/null +++ b/docs/RewardsAssignmentsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::RewardsAssignmentsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about reward assignments in a dictionary. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of reward assignments. | [default to 'data'] | +| **data** | [**Array<RewardAssignment>**](RewardAssignment.md) | | | +| **total** | **Integer** | Total number of reward assignments. | | + diff --git a/docs/RewardsAssignmentsUpdateRequestBody.md b/docs/RewardsAssignmentsUpdateRequestBody.md new file mode 100644 index 00000000..49c15f8e --- /dev/null +++ b/docs/RewardsAssignmentsUpdateRequestBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardsAssignmentsUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **parameters** | [**RewardsAssignmentsUpdateRequestBodyParameters**](RewardsAssignmentsUpdateRequestBodyParameters.md) | | [optional] | + diff --git a/docs/RewardsAssignmentsUpdateRequestBodyParameters.md b/docs/RewardsAssignmentsUpdateRequestBodyParameters.md new file mode 100644 index 00000000..02442466 --- /dev/null +++ b/docs/RewardsAssignmentsUpdateRequestBodyParameters.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **loyalty** | [**RewardsAssignmentsUpdateRequestBodyParametersLoyalty**](RewardsAssignmentsUpdateRequestBodyParametersLoyalty.md) | | [optional] | + diff --git a/docs/RewardsAssignmentsUpdateRequestBodyParametersLoyalty.md b/docs/RewardsAssignmentsUpdateRequestBodyParametersLoyalty.md new file mode 100644 index 00000000..413ee4d6 --- /dev/null +++ b/docs/RewardsAssignmentsUpdateRequestBodyParametersLoyalty.md @@ -0,0 +1,8 @@ +# VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParametersLoyalty + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Defines how many points are required to obtain the reward. | [optional] | + diff --git a/docs/RewardsAssignmentsUpdateResponseBody.md b/docs/RewardsAssignmentsUpdateResponseBody.md new file mode 100644 index 00000000..c3fd79d2 --- /dev/null +++ b/docs/RewardsAssignmentsUpdateResponseBody.md @@ -0,0 +1,15 @@ +# VoucherifySdk::RewardsAssignmentsUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward assignment ID, assigned by Voucherify. | | +| **reward_id** | **String** | Associated reward ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward assignment. | [default to 'reward_assignment'] | +| **related_object_id** | **String** | Related object ID to which the reward was assigned. | | +| **related_object_type** | **String** | Related object type to which the reward was assigned. | [default to 'campaign'] | +| **parameters** | [**RewardAssignmentParametersParameters**](RewardAssignmentParametersParameters.md) | | [optional] | + diff --git a/docs/SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion.md b/docs/SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion.md new file mode 100644 index 00000000..f60a996b --- /dev/null +++ b/docs/SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion.md @@ -0,0 +1,8 @@ +# VoucherifySdk::SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **tiers** | [**Array<PromotionTierCreateParams>**](PromotionTierCreateParams.md) | | [optional] | + diff --git a/docs/SegmentsApi.md b/docs/SegmentsApi.md new file mode 100644 index 00000000..d0810bab --- /dev/null +++ b/docs/SegmentsApi.md @@ -0,0 +1,65 @@ +# VoucherifySdk::SegmentsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**delete_segment**](SegmentsApi.md#delete_segment) | **DELETE** /v1/segments/{segmentId} | Delete Segment | + + +## delete_segment + +> delete_segment(segment_id) + +Delete Segment + +This method deletes a customer segment. + +### 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::SegmentsApi.new +segment_id = 'segment_id_example' # String | A unique customer segment ID. + +begin + # Delete Segment + api_instance.delete_segment(segment_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling SegmentsApi->delete_segment: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **segment_id** | **String** | A unique customer segment ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + diff --git a/docs/Session.md b/docs/Session.md new file mode 100644 index 00000000..b94c5181 --- /dev/null +++ b/docs/Session.md @@ -0,0 +1,11 @@ +# VoucherifySdk::Session + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **key** | **String** | The session unique ID assigned by Voucherify or your own unique session ID. Sending an existing ID will result in overwriting an existing session. If no session key is provided, then a new ID will be generated. | [optional][default to 'LOCK'] | +| **type** | **String** | This parameter is required to establish a new session. The session locks the redemption quantity by 1. | [optional][default to 'LOCK'] | +| **ttl** | **Float** | Value for the period of time that the session is active. Units for this parameter are defined by the session.ttl_unit parameter. | [optional] | +| **ttl_unit** | **String** | Defines the type of unit in which the session time is counted. | [optional] | + diff --git a/docs/SimpleCampaign.md b/docs/SimpleCampaign.md new file mode 100644 index 00000000..9753bc02 --- /dev/null +++ b/docs/SimpleCampaign.md @@ -0,0 +1,20 @@ +# VoucherifySdk::SimpleCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Campaign name. | [optional] | +| **name** | **String** | Campaign name. | [optional] | +| **campaign_type** | **String** | Type of campaign. | [optional] | +| **type** | **String** | Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **voucher** | **Object** | | [optional] | +| **lucky_draw** | **Object** | | [optional] | +| **referral_program** | [**ReferralProgram**](ReferralProgram.md) | | [optional] | +| **auto_join** | **Boolean** | Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. | [optional] | +| **join_once** | **Boolean** | If this value is set to `true`, customers will be able to join the campaign only once. | [optional] | +| **active** | **Boolean** | Indicates whether campaign is active | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the campaign was created in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the campaign. | [optional][default to 'campaign'] | + diff --git a/docs/SimpleConsent.md b/docs/SimpleConsent.md new file mode 100644 index 00000000..909db8d4 --- /dev/null +++ b/docs/SimpleConsent.md @@ -0,0 +1,10 @@ +# VoucherifySdk::SimpleConsent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | [optional] | +| **name** | **String** | | [optional] | +| **object** | **String** | | [default to 'consent'] | + diff --git a/docs/SimpleCustomer.md b/docs/SimpleCustomer.md new file mode 100644 index 00000000..c52a3687 --- /dev/null +++ b/docs/SimpleCustomer.md @@ -0,0 +1,13 @@ +# VoucherifySdk::SimpleCustomer + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The ID of an existing customer that will be linked to redemption in this request. | [optional] | +| **source_id** | **String** | A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. | [optional] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | +| **object** | **String** | The type of object represented by JSON. | [optional][default to 'customer'] | + diff --git a/docs/SimpleCustomerRequiredObjectType.md b/docs/SimpleCustomerRequiredObjectType.md new file mode 100644 index 00000000..49adcd4e --- /dev/null +++ b/docs/SimpleCustomerRequiredObjectType.md @@ -0,0 +1,13 @@ +# VoucherifySdk::SimpleCustomerRequiredObjectType + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The unique ID of a customer that is assigned by Voucherify. | [optional] | +| **source_id** | **String** | The merchant’s customer ID if it is different from the Voucherify customer ID. It is really useful in case of an integration between multiple systems. It can be a customer ID from a CRM system, database or 3rd-party service. | [optional] | +| **name** | **String** | Customer's first and last name. | [optional] | +| **email** | **String** | Customer's email address. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. | [optional] | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the customer. | [default to 'customer'] | + diff --git a/docs/SimpleOrder.md b/docs/SimpleOrder.md new file mode 100644 index 00000000..f7abc0eb --- /dev/null +++ b/docs/SimpleOrder.md @@ -0,0 +1,23 @@ +# VoucherifySdk::SimpleOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. | [optional] | +| **source_id** | **String** | Unique source ID of an existing order that will be linked to the redemption of this request. | [optional] | +| **status** | **String** | The order status. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | [optional] | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **discount_amount** | **Integer** | Sum of all order-level discounts applied to the order. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **items_discount_amount** | **Integer** | Sum of all product-specific discounts applied to the order. | [optional] | +| **items_applied_discount_amount** | **Integer** | Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` | [optional] | +| **total_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied to the order. | [optional] | +| **total_applied_discount_amount** | **Integer** | Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | [optional] | +| **total_amount** | **Integer** | Order amount after undoing all the discounts through the rollback redemption. | [optional] | +| **items** | [**Array<SimpleOrderItem>**](SimpleOrderItem.md) | Array of items applied to the order. | [optional] | +| **metadata** | **Object** | A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. | [optional] | +| **object** | **String** | The type of object represented by JSON. | [default to 'order'] | + diff --git a/docs/SimpleOrderItem.md b/docs/SimpleOrderItem.md new file mode 100644 index 00000000..bb6342a6 --- /dev/null +++ b/docs/SimpleOrderItem.md @@ -0,0 +1,18 @@ +# VoucherifySdk::SimpleOrderItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about the `order_item`. | [optional][default to 'order_item'] | +| **source_id** | **String** | The merchant’s product/SKU ID (if it is different from the Voucherify product/SKU ID). It is useful in the integration between multiple systems. It can be an ID from an eCommerce site, a database, or a third-party service. | [optional] | +| **related_object** | **String** | Used along with the source_id property, can be set to either sku or product. | [optional] | +| **product_id** | **String** | A unique product ID assigned by Voucherify. | [optional] | +| **sku_id** | **String** | A unique SKU ID assigned by Voucherify. | [optional] | +| **quantity** | **Integer** | The quantity of the particular item in the cart. | [optional] | +| **discount_quantity** | **Integer** | Number of dicounted items. | [optional] | +| **amount** | **Integer** | The total amount of the order item (price * quantity). | [optional] | +| **discount_amount** | **Integer** | Sum of all order-item-level discounts applied to the order. | [optional] | +| **applied_discount_amount** | **Integer** | This field shows the order-level discount applied. | [optional] | +| **price** | **Integer** | Unit price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. | [optional] | + diff --git a/docs/SimpleProduct.md b/docs/SimpleProduct.md new file mode 100644 index 00000000..7e28a255 --- /dev/null +++ b/docs/SimpleProduct.md @@ -0,0 +1,10 @@ +# VoucherifySdk::SimpleProduct + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID. | [optional] | +| **source_id** | **String** | Product source id. | [optional] | +| **name** | **String** | Product name. | [optional] | + diff --git a/docs/SimpleProductDiscountUnit.md b/docs/SimpleProductDiscountUnit.md new file mode 100644 index 00000000..bae147dc --- /dev/null +++ b/docs/SimpleProductDiscountUnit.md @@ -0,0 +1,10 @@ +# VoucherifySdk::SimpleProductDiscountUnit + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique product ID, assigned by Voucherify. | | +| **source_id** | **String** | Product's source ID. | [optional] | +| **name** | **String** | Product name. | | + diff --git a/docs/SimplePromotionTier.md b/docs/SimplePromotionTier.md new file mode 100644 index 00000000..9509f9dc --- /dev/null +++ b/docs/SimplePromotionTier.md @@ -0,0 +1,11 @@ +# VoucherifySdk::SimplePromotionTier + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique promotion tier ID. | [optional] | +| **name** | **String** | Name of the promotion tier. | [optional] | +| **banner** | **String** | Text to be displayed to your customers on your website. | [optional] | +| **campaign** | [**SimplePromotionTierCampaign**](SimplePromotionTierCampaign.md) | | [optional] | + diff --git a/docs/SimplePromotionTierCampaign.md b/docs/SimplePromotionTierCampaign.md new file mode 100644 index 00000000..d8de02bd --- /dev/null +++ b/docs/SimplePromotionTierCampaign.md @@ -0,0 +1,8 @@ +# VoucherifySdk::SimplePromotionTierCampaign + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique campaign ID. | [optional] | + diff --git a/docs/SimpleRedemption.md b/docs/SimpleRedemption.md new file mode 100644 index 00000000..1648207e --- /dev/null +++ b/docs/SimpleRedemption.md @@ -0,0 +1,20 @@ +# VoucherifySdk::SimpleRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | [optional] | +| **customer_id** | **String** | Unique customer ID of the redeeming customer. | [optional] | +| **tracking_id** | **String** | Hashed customer source ID. | [optional] | +| **date** | **Time** | Timestamp representing the date and time when the redemption was created in ISO 8601 format. | [optional] | +| **amount** | **Integer** | A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. | [optional] | +| **order** | [**SimpleOrder**](SimpleOrder.md) | | [optional] | +| **reward** | [**SimpleRedemptionRewardResult**](SimpleRedemptionRewardResult.md) | | [optional] | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **result** | **String** | Redemption result. | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **promotion_tier** | [**SimplePromotionTier**](SimplePromotionTier.md) | | [optional] | +| **redemption** | **String** | Unique redemption ID of the parent redemption. | [optional] | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the `redemption`. | [optional][default to 'redemption'] | + diff --git a/docs/SimpleRedemptionRewardResult.md b/docs/SimpleRedemptionRewardResult.md new file mode 100644 index 00000000..661fc2fc --- /dev/null +++ b/docs/SimpleRedemptionRewardResult.md @@ -0,0 +1,20 @@ +# VoucherifySdk::SimpleRedemptionRewardResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **customer** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **assignment_id** | **String** | Unique reward assignment ID assigned by Voucherify. | [optional] | +| **voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **product** | [**SimpleProduct**](SimpleProduct.md) | | [optional] | +| **sku** | [**SimpleSku**](SimpleSku.md) | | [optional] | +| **loyalty_tier_id** | **String** | Unique loyalty tier ID assigned by Voucherify. | [optional] | +| **id** | **String** | Unique reward ID, assigned by Voucherify. | [optional] | +| **object** | **String** | The type of object represented by the JSON. This object stores information about the reward. | [optional][default to 'reward'] | +| **name** | **String** | Reward name. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the reward was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the reward was updated in ISO 8601 format. | [optional] | +| **parameters** | **Object** | Defines how the reward is generated. | [optional] | +| **type** | **String** | Reward type. | [optional] | + diff --git a/docs/SimpleReferralTier.md b/docs/SimpleReferralTier.md new file mode 100644 index 00000000..3369883a --- /dev/null +++ b/docs/SimpleReferralTier.md @@ -0,0 +1,11 @@ +# VoucherifySdk::SimpleReferralTier + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique referral tier ID. | [optional] | +| **campaign_id** | **String** | Campaign Id. | [optional] | +| **banner** | **String** | Text to be displayed to your customers on your website. | [optional] | +| **parameters** | **Object** | Referral tier parameters | [optional] | + diff --git a/docs/SimpleSegment.md b/docs/SimpleSegment.md new file mode 100644 index 00000000..a2ee0464 --- /dev/null +++ b/docs/SimpleSegment.md @@ -0,0 +1,10 @@ +# VoucherifySdk::SimpleSegment + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique segment ID. | | +| **name** | **String** | Segment name. | | +| **object** | **String** | The type of object represented by the ID. | [default to 'segment'] | + diff --git a/docs/SimpleSku.md b/docs/SimpleSku.md new file mode 100644 index 00000000..a548e646 --- /dev/null +++ b/docs/SimpleSku.md @@ -0,0 +1,10 @@ +# VoucherifySdk::SimpleSku + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique sku ID. | [optional] | +| **source_id** | **String** | Sku source id. | [optional] | +| **sku** | **String** | Sku name. | [optional] | + diff --git a/docs/SimpleSkuDiscountUnit.md b/docs/SimpleSkuDiscountUnit.md new file mode 100644 index 00000000..fedaeb79 --- /dev/null +++ b/docs/SimpleSkuDiscountUnit.md @@ -0,0 +1,10 @@ +# VoucherifySdk::SimpleSkuDiscountUnit + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique SKU ID, assigned by Voucherify. | | +| **source_id** | **String** | Product variant's source ID. | [optional] | +| **name** | **String** | Sku name | | + diff --git a/docs/SimpleVoucher.md b/docs/SimpleVoucher.md new file mode 100644 index 00000000..633405e5 --- /dev/null +++ b/docs/SimpleVoucher.md @@ -0,0 +1,20 @@ +# VoucherifySdk::SimpleVoucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the voucher assigned by Voucherify. | [optional] | +| **code** | **String** | Voucher code. | | +| **gift** | [**Gift**](Gift.md) | | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **loyalty_card** | **Object** | Defines the loyalty card details. | [optional] | +| **type** | **String** | Type of the object. | [optional][default to 'voucher'] | +| **campaign** | **Object** | Campaign object | [optional] | +| **campaign_id** | **String** | Campaign unique ID. | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **holder_id** | **String** | Unique customer ID of campaign owner. | [optional] | +| **referrer_id** | **String** | Unique referrer ID. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the order was created in ISO 8601 format. | [optional] | +| **object** | **String** | The type of object represented by JSON. | [optional][default to 'voucher'] | + diff --git a/docs/Sku.md b/docs/Sku.md new file mode 100644 index 00000000..028d0a6b --- /dev/null +++ b/docs/Sku.md @@ -0,0 +1,19 @@ +# VoucherifySdk::Sku + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the SKU and is assigned by Voucherify. | | +| **source_id** | **String** | A unique SKU identifier from your inventory system. | | +| **product_id** | **String** | The parent product's unique ID. | | +| **sku** | **String** | Unique user-defined SKU name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the SKU was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the SKU was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the `SKU`. | [default to 'sku'] | + diff --git a/docs/SkuWithProduct.md b/docs/SkuWithProduct.md new file mode 100644 index 00000000..bc32419c --- /dev/null +++ b/docs/SkuWithProduct.md @@ -0,0 +1,20 @@ +# VoucherifySdk::SkuWithProduct + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the SKU and is assigned by Voucherify. | | +| **source_id** | **String** | A unique SKU identifier from your inventory system. | | +| **product_id** | **String** | The parent product's unique ID. | | +| **sku** | **String** | Unique user-defined SKU name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the SKU was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the SKU was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the `SKU`. | [default to 'sku'] | +| **product** | [**ProductWithoutSkus**](ProductWithoutSkus.md) | | [optional] | + diff --git a/docs/SkusGetResponseBody.md b/docs/SkusGetResponseBody.md new file mode 100644 index 00000000..0ba156fc --- /dev/null +++ b/docs/SkusGetResponseBody.md @@ -0,0 +1,19 @@ +# VoucherifySdk::SkusGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | A unique identifier that represents the SKU and is assigned by Voucherify. | | +| **source_id** | **String** | A unique SKU identifier from your inventory system. | | +| **product_id** | **String** | The parent product's unique ID. | | +| **sku** | **String** | Unique user-defined SKU name. | | +| **price** | **Integer** | Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. | | +| **currency** | **String** | SKU price currency. | [optional] | +| **attributes** | **Object** | The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. | | +| **image_url** | **String** | The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. | | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. | | +| **created_at** | **Time** | Timestamp representing the date and time when the SKU was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the SKU was updated in ISO 8601 format. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about the `SKU`. | [default to 'sku'] | + diff --git a/docs/SkusImportCsvCreateResponseBody.md b/docs/SkusImportCsvCreateResponseBody.md new file mode 100644 index 00000000..ece40a93 --- /dev/null +++ b/docs/SkusImportCsvCreateResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::SkusImportCsvCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/SkusList.md b/docs/SkusList.md new file mode 100644 index 00000000..526e6c8a --- /dev/null +++ b/docs/SkusList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::SkusList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about SKUs. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of SKUs. | [default to 'data'] | +| **skus** | [**Array<Sku>**](Sku.md) | A dictionary that contains an array of SKUs. | | +| **total** | **Integer** | Total number of SKUs in the product. | | + diff --git a/docs/SkusListForProduct.md b/docs/SkusListForProduct.md new file mode 100644 index 00000000..081d6476 --- /dev/null +++ b/docs/SkusListForProduct.md @@ -0,0 +1,11 @@ +# VoucherifySdk::SkusListForProduct + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about SKUs. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of SKUs. | [default to 'data'] | +| **data** | [**Array<Sku>**](Sku.md) | A dictionary that contains an array of SKUs. | | +| **total** | **Integer** | Total number of SKUs in the product. | | + diff --git a/docs/StackableDiscountsApi.md b/docs/StackableDiscountsApi.md new file mode 100644 index 00000000..309a3314 --- /dev/null +++ b/docs/StackableDiscountsApi.md @@ -0,0 +1,412 @@ +# VoucherifySdk::StackableDiscountsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**redeem_stacked_discounts**](StackableDiscountsApi.md#redeem_stacked_discounts) | **POST** /v1/redemptions | Redeem Stackable Discounts | +| [**redeem_stacked_discounts_client_side**](StackableDiscountsApi.md#redeem_stacked_discounts_client_side) | **POST** /client/v1/redemptions | Redeem Stackable Discounts (client-side) | +| [**rollback_stacked_redemptions**](StackableDiscountsApi.md#rollback_stacked_redemptions) | **POST** /v1/redemptions/{parentRedemptionId}/rollbacks | Rollback Stackable Redemptions | +| [**validate_stacked_discounts**](StackableDiscountsApi.md#validate_stacked_discounts) | **POST** /v1/validations | Validate Stackable Discounts | +| [**validate_stacked_discounts_client_side**](StackableDiscountsApi.md#validate_stacked_discounts_client_side) | **POST** /client/v1/validations | Validate Stackable Discounts (client-side) | + + +## redeem_stacked_discounts + +> redeem_stacked_discounts(opts) + +Redeem Stackable Discounts + +## How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: | **Field** | **Calculation** | **Description** | |:---|:---|:---| | amount | N/A | This field shows the order amount before applying any discount | | total_amount | `total_amount` = `amount` - `total_discount_amount` | This field shows the order amount after applying all the discounts | | discount_amount | `discount_amount` = `previous_discount_amount` + `applied_discount_amount` | This field sums up all order-level discounts up to and including the specific discount being calculated for the stacked redemption. | | items_discount_amount | sum(items, i => i.discount_amount) | This field sums up all product-specific discounts | | total_discount_amount | `total_discount_amount` = `discount_amount` + `items_discount_amount` | This field sums up all order-level and all product-specific discounts | | applied_discount_amount | N/A | This field shows the order-level discount applied in a particular request | | items_applied_discount_amount | sum(items, i => i.applied_discount_amount) | This field sums up all product-specific discounts applied in a particular request | | total_applied_discount_amount | `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | This field sums up all order-level and all product-specific discounts applied in a particular request | > 📘 Rollbacks > > You can't roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your [rollback request](ref:rollback-stacked-redemptions). > 📘 Also available on client-side > > This method is also accessible through public keys which you can use in client-side​ apps: mobile and web browser apps. Go to the dedicated [endpoint](ref:redeem-stacked-discounts-client-side) to learn more. > - Use `X-Client-Application-Id` as the application ID header. > - Use `X-Client-Token` as the appliction secret key header. > - Use client-side base URL. > - Use an `origin` header for your custom domain. + +### 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::StackableDiscountsApi.new +opts = { + redemptions_redeem_request_body: VoucherifySdk::RedemptionsRedeemRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # RedemptionsRedeemRequestBody | +} + +begin + # Redeem Stackable Discounts + result = api_instance.redeem_stacked_discounts(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->redeem_stacked_discounts: #{e}" +end +``` + +#### Using the redeem_stacked_discounts_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> redeem_stacked_discounts_with_http_info(opts) + +```ruby +begin + # Redeem Stackable Discounts + data, status_code, headers = api_instance.redeem_stacked_discounts_with_http_info(opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->redeem_stacked_discounts_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redemptions_redeem_request_body** | [**RedemptionsRedeemRequestBody**](RedemptionsRedeemRequestBody.md) | | [optional] | + +### Return type + +[**RedemptionsRedeemResponseBody**](RedemptionsRedeemResponseBody.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 + + +## redeem_stacked_discounts_client_side + +> redeem_stacked_discounts_client_side(origin, opts) + +Redeem Stackable Discounts (client-side) + +This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. ## How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: | **Field** | **Calculation** | **Description** | |:---|:---|:---| | amount | N/A | This field shows the order amount before applying any discount | | total_amount | `total_amount` = `amount` - `total_discount_amount` | This field shows the order amount after applying all the discounts | | discount_amount | `discount_amount` = `previous_discount_amount` + `applied_discount_amount` | This field sums up all order-level discounts up to and including the specific discount being calculated for the stacked redemption. | | items_discount_amount | sum(items, i => i.discount_amount) | This field sums up all product-specific discounts | | total_discount_amount | `total_discount_amount` = `discount_amount` + `items_discount_amount` | This field sums up all order-level and all product-specific discounts | | applied_discount_amount | N/A | This field shows the order-level discount applied in a particular request | | items_applied_discount_amount | sum(items, i => i.applied_discount_amount) | This field sums up all product-specific discounts applied in a particular request | | total_applied_discount_amount | `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` | This field sums up all order-level and all product-specific discounts applied in a particular request | > 📘 Rollbacks > > You can't roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your [rollback request](ref:rollback-stacked-redemptions). + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' +# setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-Client-Application-Id + config.api_key['X-Client-Application-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-Client-Application-Id'] = 'Bearer' + + # Configure API key authorization: X-Client-Token + config.api_key['X-Client-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-Client-Token'] = 'Bearer' +end + +api_instance = VoucherifySdk::StackableDiscountsApi.new +origin = 'origin_example' # String | Indicates the origin (scheme, hostname, and port). +opts = { + client_redemptions_redeem_request_body: VoucherifySdk::ClientRedemptionsRedeemRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # ClientRedemptionsRedeemRequestBody | +} + +begin + # Redeem Stackable Discounts (client-side) + result = api_instance.redeem_stacked_discounts_client_side(origin, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->redeem_stacked_discounts_client_side: #{e}" +end +``` + +#### Using the redeem_stacked_discounts_client_side_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> redeem_stacked_discounts_client_side_with_http_info(origin, opts) + +```ruby +begin + # Redeem Stackable Discounts (client-side) + data, status_code, headers = api_instance.redeem_stacked_discounts_client_side_with_http_info(origin, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->redeem_stacked_discounts_client_side_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **origin** | **String** | Indicates the origin (scheme, hostname, and port). | | +| **client_redemptions_redeem_request_body** | [**ClientRedemptionsRedeemRequestBody**](ClientRedemptionsRedeemRequestBody.md) | | [optional] | + +### Return type + +[**ClientRedemptionsRedeemResponseBody**](ClientRedemptionsRedeemResponseBody.md) + +### Authorization + +[X-Client-Application-Id](../README.md#X-Client-Application-Id), [X-Client-Token](../README.md#X-Client-Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## rollback_stacked_redemptions + +> rollback_stacked_redemptions(parent_redemption_id, opts) + +Rollback Stackable Redemptions + +Rollback a stackable redemption. When you rollback a stacked redemption, all child redemptions will be rolled back. Provide the parent redemption ID as the path parameter. + +### 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::StackableDiscountsApi.new +parent_redemption_id = 'parent_redemption_id_example' # String | Unique identifier of a parent redemption, e.g. `r_JQfm73zWSJFQxs3bGxweYjgm`. +opts = { + reason: 'reason_example', # String | Reason for the rollback. + tracking_id: 'tracking_id_example', # String | Customer's `source_id`. + redemptions_rollbacks_create_request_body: VoucherifySdk::RedemptionsRollbacksCreateRequestBody.new # RedemptionsRollbacksCreateRequestBody | Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. +} + +begin + # Rollback Stackable Redemptions + result = api_instance.rollback_stacked_redemptions(parent_redemption_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->rollback_stacked_redemptions: #{e}" +end +``` + +#### Using the rollback_stacked_redemptions_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> rollback_stacked_redemptions_with_http_info(parent_redemption_id, opts) + +```ruby +begin + # Rollback Stackable Redemptions + data, status_code, headers = api_instance.rollback_stacked_redemptions_with_http_info(parent_redemption_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->rollback_stacked_redemptions_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **parent_redemption_id** | **String** | Unique identifier of a parent redemption, e.g. `r_JQfm73zWSJFQxs3bGxweYjgm`. | | +| **reason** | **String** | Reason for the rollback. | [optional] | +| **tracking_id** | **String** | Customer's `source_id`. | [optional] | +| **redemptions_rollbacks_create_request_body** | [**RedemptionsRollbacksCreateRequestBody**](RedemptionsRollbacksCreateRequestBody.md) | Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. | [optional] | + +### Return type + +[**RedemptionsRollbacksCreateResponseBody**](RedemptionsRollbacksCreateResponseBody.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 + + +## validate_stacked_discounts + +> validate_stacked_discounts(opts) + +Validate Stackable Discounts + +Verify redeemables provided in the request. This method is designed for server side integration which means that it is accessible only through private keys. + +### 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::StackableDiscountsApi.new +opts = { + validations_validate_request_body: VoucherifySdk::ValidationsValidateRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # ValidationsValidateRequestBody | +} + +begin + # Validate Stackable Discounts + result = api_instance.validate_stacked_discounts(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->validate_stacked_discounts: #{e}" +end +``` + +#### Using the validate_stacked_discounts_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> validate_stacked_discounts_with_http_info(opts) + +```ruby +begin + # Validate Stackable Discounts + data, status_code, headers = api_instance.validate_stacked_discounts_with_http_info(opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->validate_stacked_discounts_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validations_validate_request_body** | [**ValidationsValidateRequestBody**](ValidationsValidateRequestBody.md) | | [optional] | + +### Return type + +[**ValidationsValidateResponseBody**](ValidationsValidateResponseBody.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 + + +## validate_stacked_discounts_client_side + +> validate_stacked_discounts_client_side(origin, opts) + +Validate Stackable Discounts (client-side) + +Verify redeemables provided in the request. This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. + +### Examples + +```ruby +require 'time' +require 'VoucherifySdk' +# setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-Client-Application-Id + config.api_key['X-Client-Application-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-Client-Application-Id'] = 'Bearer' + + # Configure API key authorization: X-Client-Token + config.api_key['X-Client-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-Client-Token'] = 'Bearer' +end + +api_instance = VoucherifySdk::StackableDiscountsApi.new +origin = 'origin_example' # String | Indicates the origin (scheme, hostname, and port). +opts = { + client_validations_validate_request_body: VoucherifySdk::ClientValidationsValidateRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # ClientValidationsValidateRequestBody | +} + +begin + # Validate Stackable Discounts (client-side) + result = api_instance.validate_stacked_discounts_client_side(origin, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->validate_stacked_discounts_client_side: #{e}" +end +``` + +#### Using the validate_stacked_discounts_client_side_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> validate_stacked_discounts_client_side_with_http_info(origin, opts) + +```ruby +begin + # Validate Stackable Discounts (client-side) + data, status_code, headers = api_instance.validate_stacked_discounts_client_side_with_http_info(origin, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue VoucherifySdk::ApiError => e + puts "Error when calling StackableDiscountsApi->validate_stacked_discounts_client_side_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **origin** | **String** | Indicates the origin (scheme, hostname, and port). | | +| **client_validations_validate_request_body** | [**ClientValidationsValidateRequestBody**](ClientValidationsValidateRequestBody.md) | | [optional] | + +### Return type + +[**ClientValidationsValidateResponseBody**](ClientValidationsValidateResponseBody.md) + +### Authorization + +[X-Client-Application-Id](../README.md#X-Client-Application-Id), [X-Client-Token](../README.md#X-Client-Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + diff --git a/docs/StackableValidateRedeemBase.md b/docs/StackableValidateRedeemBase.md new file mode 100644 index 00000000..b4f421e8 --- /dev/null +++ b/docs/StackableValidateRedeemBase.md @@ -0,0 +1,13 @@ +# VoucherifySdk::StackableValidateRedeemBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables** | [**Array<StackableValidateRedeemBaseRedeemablesItem>**](StackableValidateRedeemBaseRedeemablesItem.md) | An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. | | +| **order** | [**Order**](Order.md) | | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | +| **tracking_id** | **String** | Is correspondent to Customer's source_id | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. | [optional] | + diff --git a/docs/StackableValidateRedeemBaseRedeemablesItem.md b/docs/StackableValidateRedeemBaseRedeemablesItem.md new file mode 100644 index 00000000..1049bfdb --- /dev/null +++ b/docs/StackableValidateRedeemBaseRedeemablesItem.md @@ -0,0 +1,55 @@ +# VoucherifySdk::StackableValidateRedeemBaseRedeemablesItem + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::StackableValidateRedeemBaseRedeemablesItem.openapi_one_of +# => +# [ +# :'RedeemGiftCard', +# :'RedeemLoyaltyCard', +# :'RedeemPromotionStack', +# :'RedeemPromotionTier', +# :'RedeemVoucher' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::StackableValidateRedeemBaseRedeemablesItem.build(data) +# => # + +VoucherifySdk::StackableValidateRedeemBaseRedeemablesItem.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `RedeemGiftCard` +- `RedeemLoyaltyCard` +- `RedeemPromotionStack` +- `RedeemPromotionTier` +- `RedeemVoucher` +- `nil` (if no type matches) + diff --git a/docs/StackingRules.md b/docs/StackingRules.md new file mode 100644 index 00000000..423e8dd2 --- /dev/null +++ b/docs/StackingRules.md @@ -0,0 +1,15 @@ +# VoucherifySdk::StackingRules + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables_limit** | **Integer** | Defines how many redeemables can be sent in one stacking request (note: more redeemables means more processing time!). | [default to 30] | +| **applicable_redeemables_limit** | **Integer** | Defines how many of the sent redeemables will be applied to the order. For example, a user can select 30 discounts but only 5 will be applied to the order and the remaining will be labelled as SKIPPED. | [default to 5] | +| **applicable_exclusive_redeemables_limit** | **Integer** | Defines how many redeemables with an exclusive category can be applied in one request. | [default to 1] | +| **applicable_redeemables_per_category_limit** | **Integer** | Defines how many redeemables per category can be applied in one request. | [optional][default to 1] | +| **exclusive_categories** | **Array<String>** | Lists all exclusive categories. A redeemable from a campaign with an exclusive category is the only redeemable to be redeemed when applied with redeemables from other campaigns unless these campaigns are exclusive or joint. | | +| **joint_categories** | **Array<String>** | Lists all joint categories. A campaign with a joint category is always applied regardless of the exclusivity of other campaigns. | | +| **redeemables_application_mode** | **String** | Defines redeemables application mode. | [optional] | +| **redeemables_sorting_rule** | **String** | Defines redeemables sorting rule. | [optional][default to 'REQUESTED_ORDER'] | + diff --git a/docs/ValidationEntity.md b/docs/ValidationEntity.md new file mode 100644 index 00000000..a4c7e645 --- /dev/null +++ b/docs/ValidationEntity.md @@ -0,0 +1,15 @@ +# VoucherifySdk::ValidationEntity + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique validation id. | [optional] | +| **session_id** | **String** | Unique session id. | [optional] | +| **status** | **String** | The validation status | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the validation was created in ISO 8601 format. | [optional] | +| **customer_id** | **String** | Unique customer ID of the customer making the purchase. | [optional] | +| **redeemables** | [**Array<ValidationsRedeemableApplicable>**](ValidationsRedeemableApplicable.md) | Lists validation results of each redeemable. | [optional] | +| **skipped_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each redeemable. | [optional] | +| **inapplicable_redeemables** | [**Array<ValidationsRedeemableSkipped>**](ValidationsRedeemableSkipped.md) | Lists validation results of each redeemable. | [optional] | + diff --git a/docs/ValidationRule.md b/docs/ValidationRule.md new file mode 100644 index 00000000..8dcf9524 --- /dev/null +++ b/docs/ValidationRule.md @@ -0,0 +1,18 @@ +# VoucherifySdk::ValidationRule + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Custom, unique name for set of validation rules. | | +| **rules** | **Object** | Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. | | +| **error** | [**ValidationRuleBaseError**](ValidationRuleBaseError.md) | | [optional] | +| **applicable_to** | [**ValidationRuleBaseApplicableTo**](ValidationRuleBaseApplicableTo.md) | | | +| **type** | **String** | Type of validation rule. | [default to 'expression'] | +| **context_type** | **String** | Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | | [default to 'global'] | +| **id** | **String** | Unique validation rule ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the validation rule was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. | [optional] | +| **assignments_count** | **Integer** | The number of instances the validation rule has been assigned to different types of redeemables. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the validation rule. | [default to 'validation_rules'] | + diff --git a/docs/ValidationRuleAssignment.md b/docs/ValidationRuleAssignment.md new file mode 100644 index 00000000..e55c21ba --- /dev/null +++ b/docs/ValidationRuleAssignment.md @@ -0,0 +1,13 @@ +# VoucherifySdk::ValidationRuleAssignment + +## 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 'validation_rules_assignment'] | + diff --git a/docs/ValidationRuleAssignmentsList.md b/docs/ValidationRuleAssignmentsList.md new file mode 100644 index 00000000..52e32a28 --- /dev/null +++ b/docs/ValidationRuleAssignmentsList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ValidationRuleAssignmentsList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about validation rule assignments. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of validation rule assignments. | [default to 'data'] | +| **data** | [**Array<ValidationRuleAssignment>**](ValidationRuleAssignment.md) | A dictionary that contains an array of validation rule assignments. | | +| **total** | **Integer** | Total number of validation rule assignments. | | + diff --git a/docs/ValidationRuleBase.md b/docs/ValidationRuleBase.md new file mode 100644 index 00000000..deba2555 --- /dev/null +++ b/docs/ValidationRuleBase.md @@ -0,0 +1,13 @@ +# VoucherifySdk::ValidationRuleBase + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Custom, unique name for set of validation rules. | [optional] | +| **rules** | **Object** | Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. | [optional] | +| **error** | [**ValidationRuleBaseError**](ValidationRuleBaseError.md) | | [optional] | +| **applicable_to** | [**ValidationRuleBaseApplicableTo**](ValidationRuleBaseApplicableTo.md) | | [optional] | +| **type** | **String** | Type of validation rule. | [optional][default to 'expression'] | +| **context_type** | **String** | Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | | [optional][default to 'global'] | + diff --git a/docs/ValidationRuleBaseApplicableTo.md b/docs/ValidationRuleBaseApplicableTo.md new file mode 100644 index 00000000..a456ddfe --- /dev/null +++ b/docs/ValidationRuleBaseApplicableTo.md @@ -0,0 +1,10 @@ +# VoucherifySdk::ValidationRuleBaseApplicableTo + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **excluded** | [**Array<ApplicableTo>**](ApplicableTo.md) | Defines which items are excluded from a discount. | [optional] | +| **included** | [**Array<ApplicableTo>**](ApplicableTo.md) | Defines which items are included in a discount. | [optional] | +| **included_all** | **Boolean** | Indicates whether all items are included in the discount. | [optional] | + diff --git a/docs/ValidationRuleBaseError.md b/docs/ValidationRuleBaseError.md new file mode 100644 index 00000000..78b4a7d9 --- /dev/null +++ b/docs/ValidationRuleBaseError.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ValidationRuleBaseError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message** | **String** | The error message returned from API when validation / redemption fails to meet requirements of defined rules. | [optional] | + diff --git a/docs/ValidationRulesApi.md b/docs/ValidationRulesApi.md new file mode 100644 index 00000000..a58c1624 --- /dev/null +++ b/docs/ValidationRulesApi.md @@ -0,0 +1,513 @@ +# VoucherifySdk::ValidationRulesApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**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 | +| [**get_validation_rule**](ValidationRulesApi.md#get_validation_rule) | **GET** /v1/validation-rules/{validationRuleId} | Get Validation Rule | +| [**list_validation_rule_assignments**](ValidationRulesApi.md#list_validation_rule_assignments) | **GET** /v1/validation-rules/{validationRuleId}/assignments | List Validation Rule Assignments | +| [**list_validation_rules**](ValidationRulesApi.md#list_validation_rules) | **GET** /v1/validation-rules | List Validation Rules | +| [**list_validation_rules_assignments**](ValidationRulesApi.md#list_validation_rules_assignments) | **GET** /v1/validation-rules-assignments | List Validation Rules' Assignment(s) | +| [**update_validation_rule**](ValidationRulesApi.md#update_validation_rule) | **PUT** /v1/validation-rules/{validationRuleId} | Update Validation Rule | + + +## create_validation_rules + +> create_validation_rules(opts) + +Create Validation Rules + +Create validation rules. + +### 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 +opts = { + validation_rules_create_request_body: VoucherifySdk::ValidationRulesCreateRequestBody.new({name: 'Business Validation Rule'}) # ValidationRulesCreateRequestBody | Specify the validation rules parameters. +} + +begin + # Create Validation Rules + result = api_instance.create_validation_rules(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->create_validation_rules: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validation_rules_create_request_body** | [**ValidationRulesCreateRequestBody**](ValidationRulesCreateRequestBody.md) | Specify the validation rules parameters. | [optional] | + +### Return type + +[**ValidationRulesCreateResponseBody**](ValidationRulesCreateResponseBody.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 + + +## delete_validation_rule_assignment + +> delete_validation_rule_assignment(validation_rule_id, assignment_id) + +Delete Validation Rule Assignment + +This method deletes a validation rule assignment. + +### 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 | A unique validation rule ID. +assignment_id = 'assignment_id_example' # String | A unique validation rule assignment ID. + +begin + # Delete Validation Rule Assignment + api_instance.delete_validation_rule_assignment(validation_rule_id, assignment_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->delete_validation_rule_assignment: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validation_rule_id** | **String** | A unique validation rule ID. | | +| **assignment_id** | **String** | A unique validation rule assignment ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## delete_validation_rules + +> delete_validation_rules(validation_rule_id) + +Delete Validation Rule + +This method deletes a validation rule. + +### 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 | A unique validation rule ID. + +begin + # Delete Validation Rule + api_instance.delete_validation_rules(validation_rule_id) +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->delete_validation_rules: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validation_rule_id** | **String** | A unique validation rule ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## get_validation_rule + +> get_validation_rule(validation_rule_id) + +Get Validation Rule + +Retrieve the details of a validation rule. + +### 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 | A unique validation rule ID. + +begin + # Get Validation Rule + result = api_instance.get_validation_rule(validation_rule_id) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->get_validation_rule: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validation_rule_id** | **String** | A unique validation rule ID. | | + +### Return type + +[**ValidationRulesGetResponseBody**](ValidationRulesGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_validation_rule_assignments + +> list_validation_rule_assignments(validation_rule_id, opts) + +List Validation Rule Assignments + +Retrieve validation rule assignments for a specific validation rule. + +### 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 = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrderListValidationRuleAssignments::CREATED_AT # ParameterOrderListValidationRuleAssignments | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. +} + +begin + # List Validation Rule Assignments + result = api_instance.list_validation_rule_assignments(validation_rule_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->list_validation_rule_assignments: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validation_rule_id** | **String** | Unique validation rule ID. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrderListValidationRuleAssignments**](.md) | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | + +### Return type + +[**ValidationRulesAssignmentsListResponseBody**](ValidationRulesAssignmentsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_validation_rules + +> list_validation_rules(opts) + +List Validation Rules + +Retrieve validation rules. + +### 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 +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56, # Integer | Which page of results to return. + order: VoucherifySdk::ParameterOrderListValidationRules::CREATED_AT, # ParameterOrderListValidationRules | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + start_date: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Timestamp representing the date and time which results must start on. Represented in ISO 8601 format. + end_date: Time.parse('2013-10-20T19:20:30+01:00') # Time | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. +} + +begin + # List Validation Rules + result = api_instance.list_validation_rules(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->list_validation_rules: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **order** | [**ParameterOrderListValidationRules**](.md) | This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | +| **start_date** | **Time** | Timestamp representing the date and time which results must start on. Represented in ISO 8601 format. | [optional] | +| **end_date** | **Time** | Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. | [optional] | + +### Return type + +[**ValidationRulesListResponseBody**](ValidationRulesListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_validation_rules_assignments + +> list_validation_rules_assignments(opts) + +List Validation Rules' Assignment(s) + +List all validation rules assignments or filter the results using the related object ID or the validation rule ID query parameters. # How to retrieve specific validation rule assignments(s) ## Related object ID To find an assignment for a particular resource, you can use the ID of the object to which the validation rule was assigned. This could be, for example, an ID of a: voucher, campaign, distribution, reward assignment, earning rule, promotion tier. ## Validation rule ID You can use the validation rule ID to find assignment(s) for a specific validation rule. + +### 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 +opts = { + related_object_id: 'related_object_id_example', # String | The resource ID to which the validation rule was assigned; this could be, for example, a resource ID of a voucher, campaign, earning rule, reward assignment, promotion tier, or distribution. + rule: 'rule_example', # String | Validation rule ID. + page: 56, # Integer | Which page of results to return. + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + order: 'order_example' # String | Sorts the results using one of the filtering options: -created_at, created_at, where the dash - preceding a sorting option means sorting in a descending order. +} + +begin + # List Validation Rules' Assignment(s) + result = api_instance.list_validation_rules_assignments(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->list_validation_rules_assignments: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **related_object_id** | **String** | The resource ID to which the validation rule was assigned; this could be, for example, a resource ID of a voucher, campaign, earning rule, reward assignment, promotion tier, or distribution. | [optional] | +| **rule** | **String** | Validation rule ID. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **order** | **String** | Sorts the results using one of the filtering options: -created_at, created_at, where the dash - preceding a sorting option means sorting in a descending order. | [optional] | + +### Return type + +[**ValidationRulesAssignmentsListResponseBody**](ValidationRulesAssignmentsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_validation_rule + +> update_validation_rule(validation_rule_id, opts) + +Update Validation Rule + +Update validation rule parameters. + +### 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 | A unique validation rule ID. +opts = { + validation_rules_update_request_body: VoucherifySdk::ValidationRulesUpdateRequestBody.new # ValidationRulesUpdateRequestBody | Specify the parameters to be updated. +} + +begin + # Update Validation Rule + result = api_instance.update_validation_rule(validation_rule_id, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationRulesApi->update_validation_rule: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validation_rule_id** | **String** | A unique validation rule ID. | | +| **validation_rules_update_request_body** | [**ValidationRulesUpdateRequestBody**](ValidationRulesUpdateRequestBody.md) | Specify the parameters to be updated. | [optional] | + +### Return type + +[**ValidationRulesUpdateResponseBody**](ValidationRulesUpdateResponseBody.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 + diff --git a/docs/ValidationRulesAssignmentsList.md b/docs/ValidationRulesAssignmentsList.md new file mode 100644 index 00000000..d4621df2 --- /dev/null +++ b/docs/ValidationRulesAssignmentsList.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ValidationRulesAssignmentsList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about validation rules assignments. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of validation rules assignments. | [default to 'data'] | +| **data** | [**Array<BusValRuleAssignment>**](BusValRuleAssignment.md) | Contains array of validation rules assignments. | | +| **total** | **Integer** | Total number of validation rules assignments. | | + diff --git a/docs/ValidationRulesAssignmentsListResponseBody.md b/docs/ValidationRulesAssignmentsListResponseBody.md new file mode 100644 index 00000000..414facd6 --- /dev/null +++ b/docs/ValidationRulesAssignmentsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ValidationRulesAssignmentsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about validation rule assignments. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the JSON property that contains the array of validation rule assignments. | [default to 'data'] | +| **data** | [**Array<ValidationRuleAssignment>**](ValidationRuleAssignment.md) | A dictionary that contains an array of validation rule assignments. | | +| **total** | **Integer** | Total number of validation rule assignments. | | + diff --git a/docs/ValidationRulesCreateRequestBody.md b/docs/ValidationRulesCreateRequestBody.md new file mode 100644 index 00000000..3408b1e5 --- /dev/null +++ b/docs/ValidationRulesCreateRequestBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::ValidationRulesCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Custom, unique name for set of validation rules. | | +| **rules** | **Object** | Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. | [optional] | +| **error** | [**ValidationRuleBaseError**](ValidationRuleBaseError.md) | | [optional] | +| **applicable_to** | [**ValidationRuleBaseApplicableTo**](ValidationRuleBaseApplicableTo.md) | | [optional] | +| **type** | **String** | Type of validation rule. | [optional][default to 'expression'] | +| **context_type** | **String** | Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | | [optional][default to 'global'] | + diff --git a/docs/ValidationRulesCreateResponseBody.md b/docs/ValidationRulesCreateResponseBody.md new file mode 100644 index 00000000..92e2276b --- /dev/null +++ b/docs/ValidationRulesCreateResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::ValidationRulesCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Custom, unique name for set of validation rules. | | +| **rules** | **Object** | Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. | | +| **error** | [**ValidationRuleBaseError**](ValidationRuleBaseError.md) | | [optional] | +| **applicable_to** | [**ValidationRuleBaseApplicableTo**](ValidationRuleBaseApplicableTo.md) | | | +| **type** | **String** | Type of validation rule. | [default to 'expression'] | +| **context_type** | **String** | Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | | [default to 'global'] | +| **id** | **String** | Unique validation rule ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the validation rule was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. | [optional] | +| **assignments_count** | **Integer** | The number of instances the validation rule has been assigned to different types of redeemables. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the validation rule. | [default to 'validation_rules'] | + diff --git a/docs/ValidationRulesGetResponseBody.md b/docs/ValidationRulesGetResponseBody.md new file mode 100644 index 00000000..887e55a4 --- /dev/null +++ b/docs/ValidationRulesGetResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::ValidationRulesGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Custom, unique name for set of validation rules. | | +| **rules** | **Object** | Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. | | +| **error** | [**ValidationRuleBaseError**](ValidationRuleBaseError.md) | | [optional] | +| **applicable_to** | [**ValidationRuleBaseApplicableTo**](ValidationRuleBaseApplicableTo.md) | | | +| **type** | **String** | Type of validation rule. | [default to 'expression'] | +| **context_type** | **String** | Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | | [default to 'global'] | +| **id** | **String** | Unique validation rule ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the validation rule was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. | [optional] | +| **assignments_count** | **Integer** | The number of instances the validation rule has been assigned to different types of redeemables. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the validation rule. | [default to 'validation_rules'] | + diff --git a/docs/ValidationRulesListResponseBody.md b/docs/ValidationRulesListResponseBody.md new file mode 100644 index 00000000..77c1e9b3 --- /dev/null +++ b/docs/ValidationRulesListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ValidationRulesListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. This object stores information about validation rules. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of validation rules. | [default to 'data'] | +| **data** | [**Array<ValidationRule>**](ValidationRule.md) | An array of validation rules. | | +| **total** | **Integer** | Total number of validation rules in the project. | | + diff --git a/docs/ValidationRulesUpdateRequestBody.md b/docs/ValidationRulesUpdateRequestBody.md new file mode 100644 index 00000000..93582512 --- /dev/null +++ b/docs/ValidationRulesUpdateRequestBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::ValidationRulesUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Custom, unique name for set of validation rules. | [optional] | +| **rules** | **Object** | Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. | [optional] | +| **error** | [**ValidationRuleBaseError**](ValidationRuleBaseError.md) | | [optional] | +| **applicable_to** | [**ValidationRuleBaseApplicableTo**](ValidationRuleBaseApplicableTo.md) | | [optional] | +| **type** | **String** | Type of validation rule. | [optional][default to 'expression'] | +| **context_type** | **String** | Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | | [optional][default to 'global'] | + diff --git a/docs/ValidationRulesUpdateResponseBody.md b/docs/ValidationRulesUpdateResponseBody.md new file mode 100644 index 00000000..a1cd7232 --- /dev/null +++ b/docs/ValidationRulesUpdateResponseBody.md @@ -0,0 +1,18 @@ +# VoucherifySdk::ValidationRulesUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **name** | **String** | Custom, unique name for set of validation rules. | | +| **rules** | **Object** | Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. | | +| **error** | [**ValidationRuleBaseError**](ValidationRuleBaseError.md) | | [optional] | +| **applicable_to** | [**ValidationRuleBaseApplicableTo**](ValidationRuleBaseApplicableTo.md) | | | +| **type** | **String** | Type of validation rule. | [default to 'expression'] | +| **context_type** | **String** | Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | | [default to 'global'] | +| **id** | **String** | Unique validation rule ID. | | +| **created_at** | **Time** | Timestamp representing the date and time when the validation rule was created in ISO 8601 format. | | +| **updated_at** | **Time** | Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. | [optional] | +| **assignments_count** | **Integer** | The number of instances the validation rule has been assigned to different types of redeemables. | [optional] | +| **object** | **String** | The type of object represented by JSON. This object stores information about the validation rule. | [default to 'validation_rules'] | + diff --git a/docs/ValidationsApi.md b/docs/ValidationsApi.md new file mode 100644 index 00000000..45317c8c --- /dev/null +++ b/docs/ValidationsApi.md @@ -0,0 +1,68 @@ +# VoucherifySdk::ValidationsApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**validate_stacked_discounts**](ValidationsApi.md#validate_stacked_discounts) | **POST** /v1/validations | Validate Stackable Discounts | + + +## validate_stacked_discounts + +> validate_stacked_discounts(opts) + +Validate Stackable Discounts + +Verify redeemables provided in the request. This method is designed for server side integration which means that it is accessible only through private keys. + +### 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::ValidationsApi.new +opts = { + validations_validate_request_body: VoucherifySdk::ValidationsValidateRequestBody.new({redeemables: [VoucherifySdk::RedeemGiftCard.new({object: 'voucher', id: 'id_example'})]}) # ValidationsValidateRequestBody | +} + +begin + # Validate Stackable Discounts + result = api_instance.validate_stacked_discounts(opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling ValidationsApi->validate_stacked_discounts: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **validations_validate_request_body** | [**ValidationsValidateRequestBody**](ValidationsValidateRequestBody.md) | | [optional] | + +### Return type + +[**ValidationsValidateResponseBody**](ValidationsValidateResponseBody.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 + diff --git a/docs/ValidationsRedeemableApplicable.md b/docs/ValidationsRedeemableApplicable.md new file mode 100644 index 00000000..6d90fc28 --- /dev/null +++ b/docs/ValidationsRedeemableApplicable.md @@ -0,0 +1,16 @@ +# VoucherifySdk::ValidationsRedeemableApplicable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | **String** | Indicates whether the redeemable can be applied or not applied based on the validation rules. | [optional][default to 'APPLICABLE'] | +| **id** | **String** | Redeemable ID, i.e. the voucher code. | [optional] | +| **object** | **String** | Redeemable's object type. | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **applicable_to** | [**ApplicableToResultList**](ApplicableToResultList.md) | | [optional] | +| **inapplicable_to** | [**InapplicableToResultList**](InapplicableToResultList.md) | | [optional] | +| **result** | [**ValidationsRedeemableApplicableResult**](ValidationsRedeemableApplicableResult.md) | | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes in the form of key/value pairs assigned to the redeemable. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | | [optional] | + diff --git a/docs/ValidationsRedeemableApplicableResult.md b/docs/ValidationsRedeemableApplicableResult.md new file mode 100644 index 00000000..adebc619 --- /dev/null +++ b/docs/ValidationsRedeemableApplicableResult.md @@ -0,0 +1,55 @@ +# VoucherifySdk::ValidationsRedeemableApplicableResult + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ValidationsRedeemableApplicableResult.openapi_one_of +# => +# [ +# :'RedeemableResultGiftCard', +# :'RedeemableResultLoyaltyCard', +# :'RedeemableResultPromotionStack', +# :'RedeemableResultPromotionTier', +# :'RedeemableResultVoucherCode' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ValidationsRedeemableApplicableResult.build(data) +# => # + +VoucherifySdk::ValidationsRedeemableApplicableResult.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `RedeemableResultGiftCard` +- `RedeemableResultLoyaltyCard` +- `RedeemableResultPromotionStack` +- `RedeemableResultPromotionTier` +- `RedeemableResultVoucherCode` +- `nil` (if no type matches) + diff --git a/docs/ValidationsRedeemableInapplicable.md b/docs/ValidationsRedeemableInapplicable.md new file mode 100644 index 00000000..d6c20914 --- /dev/null +++ b/docs/ValidationsRedeemableInapplicable.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ValidationsRedeemableInapplicable + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | **String** | Indicates whether the redeemable can be applied or not applied based on the validation rules. | [optional][default to 'INAPPLICABLE'] | +| **id** | **String** | Redeemable ID, i.e. the voucher code. | [optional] | +| **object** | **String** | Redeemable's object type. | [optional] | +| **result** | [**ValidationsRedeemableInapplicableResult**](ValidationsRedeemableInapplicableResult.md) | | [optional] | + diff --git a/docs/ValidationsRedeemableInapplicableResult.md b/docs/ValidationsRedeemableInapplicableResult.md new file mode 100644 index 00000000..b69d724d --- /dev/null +++ b/docs/ValidationsRedeemableInapplicableResult.md @@ -0,0 +1,8 @@ +# VoucherifySdk::ValidationsRedeemableInapplicableResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **error** | [**Error**](Error.md) | | [optional] | + diff --git a/docs/ValidationsRedeemableSkipped.md b/docs/ValidationsRedeemableSkipped.md new file mode 100644 index 00000000..03f34506 --- /dev/null +++ b/docs/ValidationsRedeemableSkipped.md @@ -0,0 +1,11 @@ +# VoucherifySdk::ValidationsRedeemableSkipped + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | **String** | Indicates whether the redeemable can be applied or not applied based on the validation rules. | [optional][default to 'SKIPPED'] | +| **id** | **String** | Redeemable ID, i.e. the voucher code. | [optional] | +| **object** | **String** | Redeemable's object type. | [optional] | +| **result** | **Object** | | [optional] | + diff --git a/docs/ValidationsValidateAllResponseBody.md b/docs/ValidationsValidateAllResponseBody.md new file mode 100644 index 00000000..c32f0f3c --- /dev/null +++ b/docs/ValidationsValidateAllResponseBody.md @@ -0,0 +1,13 @@ +# VoucherifySdk::ValidationsValidateAllResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **valid** | **Boolean** | The result of the validation. It takes all of the redeemables into account and returns a `false` if at least one redeemable is inapplicable. Returns `true` if all redeemables are applicable. | | +| **redeemables** | [**Array<ValidationsValidateAllResponseBodyRedeemablesItem>**](ValidationsValidateAllResponseBodyRedeemablesItem.md) | Lists validation results of each redeemable. If a redeemable can be applied, the API returns `\"status\": \"APPLICABLE\"`. | | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **tracking_id** | **String** | Hashed customer source ID. | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | +| **application_mode** | **String** | | [default to 'ALL'] | + diff --git a/docs/ValidationsValidateAllResponseBodyRedeemablesItem.md b/docs/ValidationsValidateAllResponseBodyRedeemablesItem.md new file mode 100644 index 00000000..f4067b85 --- /dev/null +++ b/docs/ValidationsValidateAllResponseBodyRedeemablesItem.md @@ -0,0 +1,51 @@ +# VoucherifySdk::ValidationsValidateAllResponseBodyRedeemablesItem + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ValidationsValidateAllResponseBodyRedeemablesItem.openapi_one_of +# => +# [ +# :'ValidationsRedeemableApplicable', +# :'ValidationsRedeemableInapplicable', +# :'ValidationsRedeemableSkipped' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::ValidationsValidateAllResponseBodyRedeemablesItem.build(data) +# => # + +VoucherifySdk::ValidationsValidateAllResponseBodyRedeemablesItem.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `ValidationsRedeemableApplicable` +- `ValidationsRedeemableInapplicable` +- `ValidationsRedeemableSkipped` +- `nil` (if no type matches) + diff --git a/docs/ValidationsValidatePartialResponseBody.md b/docs/ValidationsValidatePartialResponseBody.md new file mode 100644 index 00000000..48dc0d71 --- /dev/null +++ b/docs/ValidationsValidatePartialResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ValidationsValidatePartialResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **valid** | **Boolean** | The result of the validation. It takes all of the redeemables into account and returns a `false` if at least one redeemable is inapplicable. Returns `true` if all redeemables are applicable. | | +| **redeemables** | [**Array<ValidationsRedeemableApplicable>**](ValidationsRedeemableApplicable.md) | Lists validation results of each redeemable. If a redeemable can be applied, the API returns `\"status\": \"APPLICABLE\"`. | | +| **inapplicable_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each inapplicable redeemable. | | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **tracking_id** | **String** | Hashed customer source ID. | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | +| **application_mode** | **String** | | [default to 'PARTIAL'] | + diff --git a/docs/ValidationsValidateRequestBody.md b/docs/ValidationsValidateRequestBody.md new file mode 100644 index 00000000..c573d443 --- /dev/null +++ b/docs/ValidationsValidateRequestBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ValidationsValidateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **redeemables** | [**Array<StackableValidateRedeemBaseRedeemablesItem>**](StackableValidateRedeemBaseRedeemablesItem.md) | An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. | | +| **order** | [**Order**](Order.md) | | [optional] | +| **customer** | [**Customer**](Customer.md) | | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | +| **tracking_id** | **String** | Is correspondent to Customer's source_id | [optional] | +| **metadata** | **Object** | A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. | [optional] | +| **options** | [**ClientValidationsValidateRequestBodyAllOfOptions**](ClientValidationsValidateRequestBodyAllOfOptions.md) | | [optional] | + diff --git a/docs/ValidationsValidateResponseBody.md b/docs/ValidationsValidateResponseBody.md new file mode 100644 index 00000000..1dc6098d --- /dev/null +++ b/docs/ValidationsValidateResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::ValidationsValidateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **valid** | **Boolean** | The result of the validation. It takes all of the redeemables into account and returns a `false` if at least one redeemable is inapplicable. Returns `true` if all redeemables are applicable. | | +| **redeemables** | [**Array<ValidationsValidateAllResponseBodyRedeemablesItem>**](ValidationsValidateAllResponseBodyRedeemablesItem.md) | Lists validation results of each redeemable. If redeemables_application_mode=\"PARTIAL\" all redeemables here will be \"APPLICABLE\" | | +| **skipped_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each skipped redeemable. | [optional] | +| **inapplicable_redeemables** | [**Array<ValidationsRedeemableInapplicable>**](ValidationsRedeemableInapplicable.md) | Lists validation results of each inapplicable redeemable. | [optional] | +| **order** | [**OrderCalculated**](OrderCalculated.md) | | [optional] | +| **tracking_id** | **String** | Hashed customer source ID. | [optional] | +| **session** | [**Session**](Session.md) | | [optional] | + diff --git a/docs/Voucher.md b/docs/Voucher.md new file mode 100644 index 00000000..70f496ce --- /dev/null +++ b/docs/Voucher.md @@ -0,0 +1,37 @@ +# VoucherifySdk::Voucher + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the voucher. | [optional] | +| **code** | **String** | A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. | [optional] | +| **campaign** | **String** | A unique campaign name, identifies the voucher's parent campaign. | [optional] | +| **campaign_id** | **String** | Assigned by the Voucherify API, identifies the voucher's parent campaign. | [optional] | +| **category** | **String** | Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. | [optional] | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | [optional] | +| **type** | **String** | Defines the type of the voucher. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**VoucherGift**](VoucherGift.md) | | [optional] | +| **loyalty_card** | [**VoucherLoyaltyCard**](VoucherLoyaltyCard.md) | | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**VoucherValidityTimeframe**](VoucherValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **active** | **Boolean** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **assets** | [**VoucherAssets**](VoucherAssets.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the voucher was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. | [optional] | +| **holder_id** | **String** | Unique customer ID of voucher owner. | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. Default is `voucher`. | [optional][default to 'voucher'] | +| **distributions** | **Array<Object>** | | [optional] | +| **deleted** | **Boolean** | Flag indicating whether this voucher is deleted. | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | +| **publish** | [**VoucherPublish**](VoucherPublish.md) | | [optional] | +| **redemption** | [**VoucherRedemption**](VoucherRedemption.md) | | [optional] | + diff --git a/docs/VoucherAssets.md b/docs/VoucherAssets.md new file mode 100644 index 00000000..5c91a496 --- /dev/null +++ b/docs/VoucherAssets.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherAssets + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **qr** | [**LoyaltiesMembersTransfersCreateResponseBodyAssetsQr**](LoyaltiesMembersTransfersCreateResponseBodyAssetsQr.md) | | [optional] | +| **barcode** | [**LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode**](LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode.md) | | [optional] | + diff --git a/docs/VoucherGift.md b/docs/VoucherGift.md new file mode 100644 index 00000000..4cf44576 --- /dev/null +++ b/docs/VoucherGift.md @@ -0,0 +1,10 @@ +# VoucherifySdk::VoucherGift + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **amount** | **Integer** | Total gift card income over the lifetime of the card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | [optional] | +| **balance** | **Integer** | Available funds. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | [optional] | +| **effect** | **String** | Defines how the credits are applied to the customer's order. | [optional] | + diff --git a/docs/VoucherLoyaltyCard.md b/docs/VoucherLoyaltyCard.md new file mode 100644 index 00000000..9f68badb --- /dev/null +++ b/docs/VoucherLoyaltyCard.md @@ -0,0 +1,11 @@ +# VoucherifySdk::VoucherLoyaltyCard + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **points** | **Integer** | Total points incurred over lifespan of loyalty card. | [optional] | +| **balance** | **Integer** | Points available for reward redemption. | [optional] | +| **next_expiration_date** | **Date** | The next closest date when the next set of points are due to expire. | [optional] | +| **next_expiration_points** | **Integer** | The amount of points that are set to expire next. | [optional] | + diff --git a/docs/VoucherPublish.md b/docs/VoucherPublish.md new file mode 100644 index 00000000..d759f01c --- /dev/null +++ b/docs/VoucherPublish.md @@ -0,0 +1,10 @@ +# VoucherifySdk::VoucherPublish + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented is by default `list`. To get this list, you need to make a call to the endpoint returned in the `url` attribute. | [optional][default to 'list'] | +| **count** | **Integer** | Publication events counter. | [optional] | +| **url** | **String** | The endpoint where this list of publications can be accessed using a GET method. `/v1/vouchers/{voucher_code}/publications` | [optional] | + diff --git a/docs/VoucherRedemption.md b/docs/VoucherRedemption.md new file mode 100644 index 00000000..a6fbad97 --- /dev/null +++ b/docs/VoucherRedemption.md @@ -0,0 +1,13 @@ +# VoucherifySdk::VoucherRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **quantity** | **Integer** | How many times a voucher can be redeemed. A `null` value means unlimited. | [optional] | +| **redeemed_quantity** | **Integer** | How many times a voucher has already been redeemed. | [optional] | +| **redeemed_amount** | **Integer** | Total amount redeemed. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 balance is written as 10000. | [optional] | +| **redeemed_points** | **Integer** | Total loyalty points redeemed. | [optional] | +| **object** | **String** | The type of object represented is by default `list`. To get this list, you need to make a call to the endpoint returned in the url attribute. | [optional][default to 'list'] | +| **url** | **String** | The endpoint where this list of redemptions can be accessed using a GET method. `/v1/vouchers/{voucher_code}/redemptions` | [optional] | + diff --git a/docs/VoucherTransaction.md b/docs/VoucherTransaction.md new file mode 100644 index 00000000..c778f1dd --- /dev/null +++ b/docs/VoucherTransaction.md @@ -0,0 +1,17 @@ +# VoucherifySdk::VoucherTransaction + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique transaction ID. | | +| **source_id** | **String** | The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. In case of a redemption, this value is null. | | +| **voucher_id** | **String** | Unique voucher ID. | | +| **campaign_id** | **String** | Unqiue campaign ID of the voucher's parent campaign if it is part of campaign that generates bulk codes. | | +| **source** | **String** | The channel through which the transaction took place, whether through the API or the the Dashboard. In case of a redemption, this value is null. | | +| **reason** | **String** | Reason why the transaction occurred. In case of a redemption, this value is null. | | +| **type** | [**LoyaltyCardTransactionsType**](LoyaltyCardTransactionsType.md) | | | +| **details** | [**VoucherTransactionDetails**](VoucherTransactionDetails.md) | | | +| **related_transaction_id** | **String** | The related transaction ID on the receiving card. | | +| **created_at** | **Time** | Timestamp representing the date and time when the transaction was created in ISO 8601 format. | | + diff --git a/docs/VoucherTransactionDetails.md b/docs/VoucherTransactionDetails.md new file mode 100644 index 00000000..e1cc724c --- /dev/null +++ b/docs/VoucherTransactionDetails.md @@ -0,0 +1,20 @@ +# VoucherifySdk::VoucherTransactionDetails + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **balance** | [**VoucherTransactionDetailsBalance**](VoucherTransactionDetailsBalance.md) | | [optional] | +| **order** | [**VoucherTransactionDetailsOrder**](VoucherTransactionDetailsOrder.md) | | [optional] | +| **event** | [**VoucherTransactionDetailsEvent**](VoucherTransactionDetailsEvent.md) | | [optional] | +| **earning_rule** | [**VoucherTransactionDetailsEarningRule**](VoucherTransactionDetailsEarningRule.md) | | [optional] | +| **segment** | [**VoucherTransactionDetailsSegment**](VoucherTransactionDetailsSegment.md) | | [optional] | +| **loyalty_tier** | [**VoucherTransactionDetailsLoyaltyTier**](VoucherTransactionDetailsLoyaltyTier.md) | | [optional] | +| **redemption** | [**VoucherTransactionDetailsRedemption**](VoucherTransactionDetailsRedemption.md) | | [optional] | +| **rollback** | [**VoucherTransactionDetailsRollback**](VoucherTransactionDetailsRollback.md) | | [optional] | +| **custom_event** | [**VoucherTransactionDetailsCustomEvent**](VoucherTransactionDetailsCustomEvent.md) | | [optional] | +| **event_schema** | [**VoucherTransactionDetailsEventSchema**](VoucherTransactionDetailsEventSchema.md) | | [optional] | +| **reward** | [**VoucherTransactionDetailsReward**](VoucherTransactionDetailsReward.md) | | [optional] | +| **source_voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | +| **destination_voucher** | [**SimpleVoucher**](SimpleVoucher.md) | | [optional] | + diff --git a/docs/VoucherTransactionDetailsBalance.md b/docs/VoucherTransactionDetailsBalance.md new file mode 100644 index 00000000..93865528 --- /dev/null +++ b/docs/VoucherTransactionDetailsBalance.md @@ -0,0 +1,13 @@ +# VoucherifySdk::VoucherTransactionDetailsBalance + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | The type of voucher whose balance is being adjusted due to the transaction. | [default to 'loyalty_card'] | +| **total** | **Integer** | The available points prior to the transaction. | | +| **object** | **String** | The type of object represented by the JSON. | [default to 'balance'] | +| **points** | **Integer** | The amount of points being used up in the transaction. | | +| **balance** | **Integer** | The points balance on the loyalty card after the points in the transaction are subtracted from the loyalty card. | | +| **related_object** | [**VoucherTransactionDetailsBalanceRelatedObject**](VoucherTransactionDetailsBalanceRelatedObject.md) | | | + diff --git a/docs/VoucherTransactionDetailsBalanceRelatedObject.md b/docs/VoucherTransactionDetailsBalanceRelatedObject.md new file mode 100644 index 00000000..fac080fe --- /dev/null +++ b/docs/VoucherTransactionDetailsBalanceRelatedObject.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsBalanceRelatedObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Identifies the voucher that is being modified, this is the ID that was assigned by the Voucherify API. | | +| **type** | **String** | The object being modified, i.e. voucher. | [default to 'voucher'] | + diff --git a/docs/VoucherTransactionDetailsCustomEvent.md b/docs/VoucherTransactionDetailsCustomEvent.md new file mode 100644 index 00000000..af432a63 --- /dev/null +++ b/docs/VoucherTransactionDetailsCustomEvent.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsCustomEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique event ID. | | +| **type** | **String** | Type of custom event. | | + diff --git a/docs/VoucherTransactionDetailsEarningRule.md b/docs/VoucherTransactionDetailsEarningRule.md new file mode 100644 index 00000000..720847e4 --- /dev/null +++ b/docs/VoucherTransactionDetailsEarningRule.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsEarningRule + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique earning rule ID. | | +| **source** | [**VoucherTransactionDetailsEarningRuleSource**](VoucherTransactionDetailsEarningRuleSource.md) | | | + diff --git a/docs/VoucherTransactionDetailsEarningRuleSource.md b/docs/VoucherTransactionDetailsEarningRuleSource.md new file mode 100644 index 00000000..108a8f34 --- /dev/null +++ b/docs/VoucherTransactionDetailsEarningRuleSource.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VoucherTransactionDetailsEarningRuleSource + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **banner** | **String** | Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. | | + diff --git a/docs/VoucherTransactionDetailsEvent.md b/docs/VoucherTransactionDetailsEvent.md new file mode 100644 index 00000000..51925067 --- /dev/null +++ b/docs/VoucherTransactionDetailsEvent.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsEvent + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique event ID. | | +| **type** | **String** | Type of event. | | + diff --git a/docs/VoucherTransactionDetailsEventSchema.md b/docs/VoucherTransactionDetailsEventSchema.md new file mode 100644 index 00000000..9f404316 --- /dev/null +++ b/docs/VoucherTransactionDetailsEventSchema.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsEventSchema + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique metadata schema ID. | | +| **name** | **String** | Type of custom event. | | + diff --git a/docs/VoucherTransactionDetailsLoyaltyTier.md b/docs/VoucherTransactionDetailsLoyaltyTier.md new file mode 100644 index 00000000..a17c354c --- /dev/null +++ b/docs/VoucherTransactionDetailsLoyaltyTier.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsLoyaltyTier + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | | +| **name** | **String** | | | + diff --git a/docs/VoucherTransactionDetailsOrder.md b/docs/VoucherTransactionDetailsOrder.md new file mode 100644 index 00000000..12b09bf6 --- /dev/null +++ b/docs/VoucherTransactionDetailsOrder.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsOrder + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique order ID. | | +| **source_id** | **String** | The merchant’s order ID if it is different from the Voucherify order ID. It is really useful in case of integration between multiple systems. It can be an order ID from CRM, database or 3rd party service. | | + diff --git a/docs/VoucherTransactionDetailsRedemption.md b/docs/VoucherTransactionDetailsRedemption.md new file mode 100644 index 00000000..cd7c00d9 --- /dev/null +++ b/docs/VoucherTransactionDetailsRedemption.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VoucherTransactionDetailsRedemption + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption ID. | | + diff --git a/docs/VoucherTransactionDetailsReward.md b/docs/VoucherTransactionDetailsReward.md new file mode 100644 index 00000000..19541be1 --- /dev/null +++ b/docs/VoucherTransactionDetailsReward.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsReward + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique reward ID. | | +| **name** | **String** | Reward name. | | + diff --git a/docs/VoucherTransactionDetailsRollback.md b/docs/VoucherTransactionDetailsRollback.md new file mode 100644 index 00000000..ee9e3a3e --- /dev/null +++ b/docs/VoucherTransactionDetailsRollback.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VoucherTransactionDetailsRollback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique redemption rollback ID. | | + diff --git a/docs/VoucherTransactionDetailsSegment.md b/docs/VoucherTransactionDetailsSegment.md new file mode 100644 index 00000000..92f4ab15 --- /dev/null +++ b/docs/VoucherTransactionDetailsSegment.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionDetailsSegment + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | | +| **name** | **String** | | | + diff --git a/docs/VoucherTransactionsExport.md b/docs/VoucherTransactionsExport.md new file mode 100644 index 00000000..882085e2 --- /dev/null +++ b/docs/VoucherTransactionsExport.md @@ -0,0 +1,16 @@ +# VoucherifySdk::VoucherTransactionsExport + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the `export`. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [default to 'API'] | +| **exported_object** | **String** | The type of exported object. | [default to 'voucher_transactions'] | +| **parameters** | [**VoucherTransactionsFilters**](VoucherTransactionsFilters.md) | | | +| **result** | [**VoucherTransactionsExportResult**](VoucherTransactionsExportResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the `channel` value is `WEBSITE`. | | + diff --git a/docs/VoucherTransactionsExportFilterConditions.md b/docs/VoucherTransactionsExportFilterConditions.md new file mode 100644 index 00000000..a77447df --- /dev/null +++ b/docs/VoucherTransactionsExportFilterConditions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VoucherTransactionsExportFilterConditions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **voucher_id** | [**VoucherTransactionsExportFilterConditionsVoucherId**](VoucherTransactionsExportFilterConditionsVoucherId.md) | | | + diff --git a/docs/VoucherTransactionsExportFilterConditionsVoucherId.md b/docs/VoucherTransactionsExportFilterConditionsVoucherId.md new file mode 100644 index 00000000..ec59238d --- /dev/null +++ b/docs/VoucherTransactionsExportFilterConditionsVoucherId.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherId + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **conditions** | [**VoucherTransactionsExportFilterConditionsVoucherIdConditions**](VoucherTransactionsExportFilterConditionsVoucherIdConditions.md) | | | + diff --git a/docs/VoucherTransactionsExportFilterConditionsVoucherIdConditions.md b/docs/VoucherTransactionsExportFilterConditionsVoucherIdConditions.md new file mode 100644 index 00000000..d3924b1a --- /dev/null +++ b/docs/VoucherTransactionsExportFilterConditionsVoucherIdConditions.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherIdConditions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **_in** | **Array<String>** | | | + diff --git a/docs/VoucherTransactionsExportParameters.md b/docs/VoucherTransactionsExportParameters.md new file mode 100644 index 00000000..3216064c --- /dev/null +++ b/docs/VoucherTransactionsExportParameters.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherTransactionsExportParameters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | **String** | How the export is filtered, where the dash `-` preceding a sorting option means sorting in a descending order. | [optional] | +| **fields** | **Array<String>** | Array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields: | **Field** | **Definition** | **Example Export** | |:---|:---|:---| | id | Unique transaction ID. | vtx_0cb7811f1c07765800 | | type | Transaction type. | - `CREDITS_REMOVAL` <br> - `CREDITS_ADDITION` <br> - `CREDITS_REFUND` <br> - `CREDITS_REDEMPTION` <br> - `POINTS_ACCRUAL` <br> - `POINTS_CANCELLATION` <br> - `POINTS_REDEMPTION`<br> - `POINTS_REFUND`<br> - `POINTS_ADDITION`<br> - `POINTS_REMOVAL`<br> - `POINTS_EXPIRATION`<br> - `POINTS_TRANSFER_IN`<br> - `POINTS_TRANSFER_OUT` | | source_id | Unique transaction source ID. | 8638 | | reason | Contains the reason for the transaction if one was included originally. | | | balance | The gift card or loyalty card balance after the transaction. | | | amount | The amount of gift card or loyalty card credits being allocated during the transaction. This value can either be negative or positive depending on the nature of the transaction. | | | created_at | Timestamp in ISO 8601 format representing the date and time when the transaction was created. | 2022-03-09T09:16:32.521Z | | voucher_id | Unique Voucher ID. | v_dky7ksKfPX50Wb2Bxvcoeb1xT20b6tcp | | campaign_id | Parent campaign ID. | camp_FNYR4jhqZBM9xTptxDGgeNBV | | source| Channel through which the transaction was initiated. | API | | details | More detailed information stored in the form of a JSON. | Provides more details related to the transaction in the form of an object. | | related_transaction_id | Unique transaction ID related to a receiver/donor card in the case of a points transfer from/to another card. | vtx_0c9afe802593b34b80 | | [optional] | + diff --git a/docs/VoucherTransactionsExportResult.md b/docs/VoucherTransactionsExportResult.md new file mode 100644 index 00000000..0b7abe98 --- /dev/null +++ b/docs/VoucherTransactionsExportResult.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VoucherTransactionsExportResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **url** | **String** | URL of the CSV file location. It contains the `token` used for authorization in the <!-- [Download export](OpenAPI.json/paths/~1exports~1{export_Id}/get) -->[Download export](ref:download-export) method. | | + diff --git a/docs/VoucherTransactionsFilters.md b/docs/VoucherTransactionsFilters.md new file mode 100644 index 00000000..a94a4a6a --- /dev/null +++ b/docs/VoucherTransactionsFilters.md @@ -0,0 +1,10 @@ +# VoucherifySdk::VoucherTransactionsFilters + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **order** | **String** | How the export is filtered, where the dash `-` preceding a sorting option means sorting in a descending order. | [optional] | +| **fields** | **Array<String>** | Array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields: | **Field** | **Definition** | **Example Export** | |:---|:---|:---| | id | Unique transaction ID. | vtx_0cb7811f1c07765800 | | type | Transaction type. | - `CREDITS_REMOVAL` <br> - `CREDITS_ADDITION` <br> - `CREDITS_REFUND` <br> - `CREDITS_REDEMPTION` <br> - `POINTS_ACCRUAL` <br> - `POINTS_CANCELLATION` <br> - `POINTS_REDEMPTION`<br> - `POINTS_REFUND`<br> - `POINTS_ADDITION`<br> - `POINTS_REMOVAL`<br> - `POINTS_EXPIRATION`<br> - `POINTS_TRANSFER_IN`<br> - `POINTS_TRANSFER_OUT` | | source_id | Unique transaction source ID. | 8638 | | reason | Contains the reason for the transaction if one was included originally. | | | balance | The gift card or loyalty card balance after the transaction. | | | amount | The amount of gift card or loyalty card credits being allocated during the transaction. This value can either be negative or positive depending on the nature of the transaction. | | | created_at | Timestamp in ISO 8601 format representing the date and time when the transaction was created. | 2022-03-09T09:16:32.521Z | | voucher_id | Unique Voucher ID. | v_dky7ksKfPX50Wb2Bxvcoeb1xT20b6tcp | | campaign_id | Parent campaign ID. | camp_FNYR4jhqZBM9xTptxDGgeNBV | | source| Channel through which the transaction was initiated. | API | | details | More detailed information stored in the form of a JSON. | Provides more details related to the transaction in the form of an object. | | related_transaction_id | Unique transaction ID related to a receiver/donor card in the case of a points transfer from/to another card. | vtx_0c9afe802593b34b80 | | [optional] | +| **filters** | [**VoucherTransactionsExportFilterConditions**](VoucherTransactionsExportFilterConditions.md) | | | + diff --git a/docs/VoucherValidityTimeframe.md b/docs/VoucherValidityTimeframe.md new file mode 100644 index 00000000..16cc3561 --- /dev/null +++ b/docs/VoucherValidityTimeframe.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VoucherValidityTimeframe + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **duration** | **String** | Defines the amount of time the voucher will be active in ISO 8601 format. For example, a voucher with a `duration` of `PT1H` will be valid for a duration of one hour. | [optional] | +| **interval** | **String** | Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a voucher with an `interval` of `P2D` will be active every other day. | [optional] | + diff --git a/docs/VouchersApi.md b/docs/VouchersApi.md new file mode 100644 index 00000000..3d7ed2c2 --- /dev/null +++ b/docs/VouchersApi.md @@ -0,0 +1,554 @@ +# VoucherifySdk::VouchersApi + +All URIs are relative to *https://api.voucherify.io* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**delete_voucher**](VouchersApi.md#delete_voucher) | **DELETE** /v1/vouchers/{code} | Delete Voucher | +| [**disable_voucher**](VouchersApi.md#disable_voucher) | **POST** /v1/vouchers/{code}/disable | Disable Voucher | +| [**enable_voucher**](VouchersApi.md#enable_voucher) | **POST** /v1/vouchers/{code}/enable | Enable Voucher | +| [**export_voucher_transactions**](VouchersApi.md#export_voucher_transactions) | **POST** /v1/vouchers/{code}/transactions/export | Export Voucher Transactions | +| [**get_voucher**](VouchersApi.md#get_voucher) | **GET** /v1/vouchers/{code} | Get Voucher | +| [**import_vouchers_using_csv**](VouchersApi.md#import_vouchers_using_csv) | **POST** /v1/vouchers/importCSV | Import Vouchers using CSV | +| [**list_voucher_transactions**](VouchersApi.md#list_voucher_transactions) | **GET** /v1/vouchers/{code}/transactions | List Voucher Transactions | +| [**release_validation_session**](VouchersApi.md#release_validation_session) | **DELETE** /v1/vouchers/{code}/sessions/{sessionKey} | Release Validation Session | +| [**update_voucher_balance**](VouchersApi.md#update_voucher_balance) | **POST** /v1/vouchers/{code}/balance | Add or Remove Voucher Balance | + + +## delete_voucher + +> delete_voucher(code, opts) + +Delete Voucher + +Deletes a voucher. This operation cannot be undone. Additionally, this operation removes any redemptions on the voucher. + +### 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::VouchersApi.new +code = 'code_example' # String | A unique **code** that identifies the voucher. +opts = { + force: true # Boolean | If this flag is set to true, the voucher will be removed permanently. Going forward, the user will be able to create another voucher with exactly the same code. +} + +begin + # Delete Voucher + api_instance.delete_voucher(code, opts) +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->delete_voucher: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A unique **code** that identifies the voucher. | | +| **force** | **Boolean** | If this flag is set to true, the voucher will be removed permanently. Going forward, the user will be able to create another voucher with exactly the same code. | [optional] | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## disable_voucher + +> disable_voucher(code) + +Disable Voucher + +There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - *enable* and *disable*. ___ This method sets the voucher state to **inactive**. The voucher cannot be redeemed. + +### 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::VouchersApi.new +code = 'code_example' # String | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + +begin + # Disable Voucher + result = api_instance.disable_voucher(code) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->disable_voucher: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. | | + +### Return type + +[**VouchersDisableResponseBody**](VouchersDisableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## enable_voucher + +> enable_voucher(code) + +Enable Voucher + +There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - *enable* and *disable*. ___ The method sets the voucher state to **active**. The voucher can be redeemed - only if the redemption occurs after the start date and the voucher is not expired. + +### 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::VouchersApi.new +code = 'code_example' # String | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + +begin + # Enable Voucher + result = api_instance.enable_voucher(code) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->enable_voucher: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. | | + +### Return type + +[**VouchersEnableResponseBody**](VouchersEnableResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## export_voucher_transactions + +> export_voucher_transactions(code, opts) + +Export Voucher Transactions + +Export transactions that are associated with credit movements on a gift card or loyalty card. + +### 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::VouchersApi.new +code = 'GIFT-CARD-1' # String | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. +opts = { + vouchers_transactions_export_create_request_body: VoucherifySdk::VouchersTransactionsExportCreateRequestBody.new # VouchersTransactionsExportCreateRequestBody | Specify the parameters for the transaction export. +} + +begin + # Export Voucher Transactions + result = api_instance.export_voucher_transactions(code, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->export_voucher_transactions: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. | | +| **vouchers_transactions_export_create_request_body** | [**VouchersTransactionsExportCreateRequestBody**](VouchersTransactionsExportCreateRequestBody.md) | Specify the parameters for the transaction export. | [optional] | + +### Return type + +[**VouchersTransactionsExportCreateResponseBody**](VouchersTransactionsExportCreateResponseBody.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 + + +## get_voucher + +> get_voucher(code) + +Get Voucher + +Retrieves the voucher with the given code or unique Voucherify ID. You can either pass the voucher ID which was assigned by Voucherify, e.g., v_7HxHkf4VAkMuc8u4lZs78lyRwhRze5UE, or the code of the voucher as the path parameter value, e.g., 7fjWdr. + +### 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::VouchersApi.new +code = 'code_example' # String | A unique **code** that identifies the voucher. + +begin + # Get Voucher + result = api_instance.get_voucher(code) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->get_voucher: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A unique **code** that identifies the voucher. | | + +### Return type + +[**VouchersGetResponseBody**](VouchersGetResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## import_vouchers_using_csv + +> import_vouchers_using_csv(file) + +Import Vouchers using CSV + +Import standalone vouchers into the repository using a CSV file. The CSV file has to include headers in the first line. All properties listed in the file headers that cannot be mapped to standard voucher fields will be added to the metadata object. You can find an example CSV file [here](https://support.voucherify.io/article/45-import-codes-and-share-them-digitally#coupons). ___ 📘 Standard voucher fields mapping - Go to the import vouchers endpoint to see all standard CSV fields description (body params section). - Supported CSV file headers: Code,Voucher Type,Value,Discount Type,Category,Start Date,Expiration Date,Redemption Limit,Redeemed Quantity, Redeemed Amount,Active,Additional Info,Custom Metadata Property Name - **Start and expiration dates** need to be provided in compliance with the ISO 8601 norms. For example, 2020-03-11T09:00:00.000Z. - YYYY-MM-DD - YYYY-MM-DDTHH - YYYY-MM-DDTHH:mm - YYYY-MM-DDTHH:mm:ss - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ss.SSSZ - Custom code attributes (not supported by-default) need to be added as code **metadata**. - You **cannot import the same codes** to a single Voucherify Project. 📘 Categories In the structure representing your data, you can define a category that the voucher belongs to. You can later use the category of a voucher to group and search by specific criteria in the Dashboard and using the List Vouchers endpoint. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + +### 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::VouchersApi.new +file = File.new('/path/to/some/file') # File | File path. + +begin + # Import Vouchers using CSV + result = api_instance.import_vouchers_using_csv(file) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->import_vouchers_using_csv: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **file** | **File** | File path. | | + +### Return type + +[**VouchersImportCsvCreateResponseBody**](VouchersImportCsvCreateResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + + +## list_voucher_transactions + +> list_voucher_transactions(code, opts) + +List Voucher Transactions + +List transactions that are associated with credit movements on a gift card or loyalty card. + +### 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::VouchersApi.new +code = 'code_example' # String | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. +opts = { + limit: 56, # Integer | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + page: 56 # Integer | Which page of results to return. +} + +begin + # List Voucher Transactions + result = api_instance.list_voucher_transactions(code, opts) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->list_voucher_transactions: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. | | +| **limit** | **Integer** | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | [optional] | +| **page** | **Integer** | Which page of results to return. | [optional] | + +### Return type + +[**VouchersTransactionsListResponseBody**](VouchersTransactionsListResponseBody.md) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## release_validation_session + +> release_validation_session(code, session_key) + +Release Validation Session + +Manually release a validation session that has been set up for the voucher. This method undos the actions that are explained in our guide on how a validation session was established, you can read more here. 📘 Release Session using Dashboard You can also use the Validations Manager in the Dashboard to unlock sessions. [Read more](https://support.voucherify.io/article/16-dashboard-sections#validations). + +### 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::VouchersApi.new +code = 'code_example' # String | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify. +session_key = 'ssn_yQGMTeKBSw8OOuFPwlBEjzGy8d8VA9Ts' # String | A unique session identifier. + +begin + # Release Validation Session + api_instance.release_validation_session(code, session_key) +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->release_validation_session: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify. | | +| **session_key** | **String** | A unique session identifier. | | + +### Return type + +nil (empty response body) + +### Authorization + +[X-App-Id](../README.md#X-App-Id), [X-App-Token](../README.md#X-App-Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + + +## update_voucher_balance + +> update_voucher_balance(code, vouchers_balance_update_request_body) + +Add or Remove Voucher Balance + +Add balance to an existing gift card or loyalty card. + +### 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::VouchersApi.new +code = 'code_example' # String | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. +vouchers_balance_update_request_body = VoucherifySdk::VouchersBalanceUpdateRequestBody.new({amount: 37}) # VouchersBalanceUpdateRequestBody | Provide the amount to be added to/subtracted from the voucher. + +begin + # Add or Remove Voucher Balance + result = api_instance.update_voucher_balance(code, vouchers_balance_update_request_body) + p result +rescue VoucherifySdk::ApiError => e + puts "Error when calling VouchersApi->update_voucher_balance: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **code** | **String** | A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. | | +| **vouchers_balance_update_request_body** | [**VouchersBalanceUpdateRequestBody**](VouchersBalanceUpdateRequestBody.md) | Provide the amount to be added to/subtracted from the voucher. | | + +### Return type + +[**VouchersBalanceUpdateResponseBody**](VouchersBalanceUpdateResponseBody.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 + diff --git a/docs/VouchersBalanceUpdateRequestBody.md b/docs/VouchersBalanceUpdateRequestBody.md new file mode 100644 index 00000000..f6ed0e5d --- /dev/null +++ b/docs/VouchersBalanceUpdateRequestBody.md @@ -0,0 +1,10 @@ +# VoucherifySdk::VouchersBalanceUpdateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **amount** | **Integer** | The incremental amount to be added to or removed from the current balance on the gift card or loyalty card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. To remove balance, simply add a minus sign before the value, i.e. to remove $20, use -2000. | | +| **source_id** | **String** | The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. | [optional] | +| **reason** | **String** | Reason why the transaction occurred. | [optional] | + diff --git a/docs/VouchersBalanceUpdateResponseBody.md b/docs/VouchersBalanceUpdateResponseBody.md new file mode 100644 index 00000000..0e9b975a --- /dev/null +++ b/docs/VouchersBalanceUpdateResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::VouchersBalanceUpdateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **amount** | **Integer** | The incremental amount added (positive integer) or subtracted (negative integer) to the current balance on the gift card or loyalty card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | | +| **total** | **Integer** | Total income incurred over the lifespan of the gift card or loyalty card. | | +| **balance** | **Integer** | The balance after adding or subtracting a specified amount. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. | | +| **type** | **String** | The type of voucher being modified. | | +| **operation_type** | **String** | | [default to 'MANUAL'] | +| **object** | **String** | The type of object represented by JSON. Default is `balance`. | [default to 'balance'] | +| **related_object** | [**VouchersBalanceUpdateResponseBodyRelatedObject**](VouchersBalanceUpdateResponseBodyRelatedObject.md) | | | + diff --git a/docs/VouchersBalanceUpdateResponseBodyRelatedObject.md b/docs/VouchersBalanceUpdateResponseBodyRelatedObject.md new file mode 100644 index 00000000..b9795ca0 --- /dev/null +++ b/docs/VouchersBalanceUpdateResponseBodyRelatedObject.md @@ -0,0 +1,9 @@ +# VoucherifySdk::VouchersBalanceUpdateResponseBodyRelatedObject + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | The object being modified, i.e. `voucher`. | [default to 'voucher'] | +| **id** | **String** | Identifies the voucher that is being modified, this is the ID that was assigned by the Voucherify API. | | + diff --git a/docs/VouchersDisableResponseBody.md b/docs/VouchersDisableResponseBody.md new file mode 100644 index 00000000..0698724e --- /dev/null +++ b/docs/VouchersDisableResponseBody.md @@ -0,0 +1,37 @@ +# VoucherifySdk::VouchersDisableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the voucher. | [optional] | +| **code** | **String** | A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. | [optional] | +| **campaign** | **String** | A unique campaign name, identifies the voucher's parent campaign. | [optional] | +| **campaign_id** | **String** | Assigned by the Voucherify API, identifies the voucher's parent campaign. | [optional] | +| **category** | **String** | Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. | [optional] | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | [optional] | +| **type** | **String** | Defines the type of the voucher. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**VoucherGift**](VoucherGift.md) | | [optional] | +| **loyalty_card** | [**VoucherLoyaltyCard**](VoucherLoyaltyCard.md) | | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**VoucherValidityTimeframe**](VoucherValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **active** | **Boolean** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **assets** | [**VoucherAssets**](VoucherAssets.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the voucher was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. | [optional] | +| **holder_id** | **String** | Unique customer ID of voucher owner. | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. Default is `voucher`. | [optional][default to 'voucher'] | +| **distributions** | **Array<Object>** | | [optional] | +| **deleted** | **Boolean** | Flag indicating whether this voucher is deleted. | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | +| **publish** | [**VoucherPublish**](VoucherPublish.md) | | [optional] | +| **redemption** | [**VoucherRedemption**](VoucherRedemption.md) | | [optional] | + diff --git a/docs/VouchersEnableResponseBody.md b/docs/VouchersEnableResponseBody.md new file mode 100644 index 00000000..844adc5c --- /dev/null +++ b/docs/VouchersEnableResponseBody.md @@ -0,0 +1,37 @@ +# VoucherifySdk::VouchersEnableResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the voucher. | [optional] | +| **code** | **String** | A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. | [optional] | +| **campaign** | **String** | A unique campaign name, identifies the voucher's parent campaign. | [optional] | +| **campaign_id** | **String** | Assigned by the Voucherify API, identifies the voucher's parent campaign. | [optional] | +| **category** | **String** | Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. | [optional] | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | [optional] | +| **type** | **String** | Defines the type of the voucher. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**VoucherGift**](VoucherGift.md) | | [optional] | +| **loyalty_card** | [**VoucherLoyaltyCard**](VoucherLoyaltyCard.md) | | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**VoucherValidityTimeframe**](VoucherValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **active** | **Boolean** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **assets** | [**VoucherAssets**](VoucherAssets.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the voucher was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. | [optional] | +| **holder_id** | **String** | Unique customer ID of voucher owner. | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. Default is `voucher`. | [optional][default to 'voucher'] | +| **distributions** | **Array<Object>** | | [optional] | +| **deleted** | **Boolean** | Flag indicating whether this voucher is deleted. | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | +| **publish** | [**VoucherPublish**](VoucherPublish.md) | | [optional] | +| **redemption** | [**VoucherRedemption**](VoucherRedemption.md) | | [optional] | + diff --git a/docs/VouchersGetResponseBody.md b/docs/VouchersGetResponseBody.md new file mode 100644 index 00000000..ffe34cc9 --- /dev/null +++ b/docs/VouchersGetResponseBody.md @@ -0,0 +1,37 @@ +# VoucherifySdk::VouchersGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Assigned by the Voucherify API, identifies the voucher. | [optional] | +| **code** | **String** | A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. | [optional] | +| **campaign** | **String** | A unique campaign name, identifies the voucher's parent campaign. | [optional] | +| **campaign_id** | **String** | Assigned by the Voucherify API, identifies the voucher's parent campaign. | [optional] | +| **category** | **String** | Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. | [optional] | +| **category_id** | **String** | Unique category ID assigned by Voucherify. | [optional] | +| **categories** | [**Array<Category>**](Category.md) | Contains details about the category. | [optional] | +| **type** | **String** | Defines the type of the voucher. | [optional] | +| **discount** | [**Discount**](Discount.md) | | [optional] | +| **gift** | [**VoucherGift**](VoucherGift.md) | | [optional] | +| **loyalty_card** | [**VoucherLoyaltyCard**](VoucherLoyaltyCard.md) | | [optional] | +| **start_date** | **Time** | Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. | [optional] | +| **expiration_date** | **Time** | Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. | [optional] | +| **validity_timeframe** | [**VoucherValidityTimeframe**](VoucherValidityTimeframe.md) | | [optional] | +| **validity_day_of_week** | **Array<Integer>** | Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday | [optional] | +| **active** | **Boolean** | A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher | [optional] | +| **additional_info** | **String** | An optional field to keep any extra textual information about the code such as a code description and details. | [optional] | +| **metadata** | **Object** | The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. | [optional] | +| **assets** | [**VoucherAssets**](VoucherAssets.md) | | [optional] | +| **is_referral_code** | **Boolean** | Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. | [optional] | +| **created_at** | **Time** | Timestamp representing the date and time when the voucher was created in ISO 8601 format. | [optional] | +| **updated_at** | **Time** | Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. | [optional] | +| **holder_id** | **String** | Unique customer ID of voucher owner. | [optional] | +| **holder** | [**SimpleCustomer**](SimpleCustomer.md) | | [optional] | +| **object** | **String** | The type of object represented by JSON. Default is `voucher`. | [optional][default to 'voucher'] | +| **distributions** | **Array<Object>** | | [optional] | +| **deleted** | **Boolean** | Flag indicating whether this voucher is deleted. | [optional] | +| **validation_rules_assignments** | [**ValidationRulesAssignmentsList**](ValidationRulesAssignmentsList.md) | | [optional] | +| **publish** | [**VoucherPublish**](VoucherPublish.md) | | [optional] | +| **redemption** | [**VoucherRedemption**](VoucherRedemption.md) | | [optional] | + diff --git a/docs/VouchersImportCsvCreateResponseBody.md b/docs/VouchersImportCsvCreateResponseBody.md new file mode 100644 index 00000000..d4369a12 --- /dev/null +++ b/docs/VouchersImportCsvCreateResponseBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VouchersImportCsvCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **async_action_id** | **String** | The ID of the scheduled asynchronous action. | | + diff --git a/docs/VouchersRedemptionGetResponseBody.md b/docs/VouchersRedemptionGetResponseBody.md new file mode 100644 index 00000000..a6b9ee0e --- /dev/null +++ b/docs/VouchersRedemptionGetResponseBody.md @@ -0,0 +1,14 @@ +# VoucherifySdk::VouchersRedemptionGetResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **quantity** | **Integer** | The maximum number of times a voucher can be redeemed. | | +| **redeemed_quantity** | **Integer** | The number of times the voucher was redeemed successfully. | | +| **object** | **String** | The type of object represented by JSON. This object stores information about redemptions in a dictionary. | [default to 'list'] | +| **url** | **String** | URL | | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of `redemption_entries`. | [default to 'redemption_entries'] | +| **total** | **Integer** | Total number of redemption objects. | | +| **redemption_entries** | [**Array<VouchersRedemptionGetResponseBodyRedemptionEntriesItem>**](VouchersRedemptionGetResponseBodyRedemptionEntriesItem.md) | Contains the array of successful and failed redemption objects. | | + diff --git a/docs/VouchersRedemptionGetResponseBodyRedemptionEntriesItem.md b/docs/VouchersRedemptionGetResponseBodyRedemptionEntriesItem.md new file mode 100644 index 00000000..691c8e35 --- /dev/null +++ b/docs/VouchersRedemptionGetResponseBodyRedemptionEntriesItem.md @@ -0,0 +1,49 @@ +# VoucherifySdk::VouchersRedemptionGetResponseBodyRedemptionEntriesItem + +## Class instance methods + +### `openapi_one_of` + +Returns the list of classes defined in oneOf. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::VouchersRedemptionGetResponseBodyRedemptionEntriesItem.openapi_one_of +# => +# [ +# :'Redemption', +# :'RedemptionRollback' +# ] +``` + +### build + +Find the appropriate object from the `openapi_one_of` list and casts the data into it. + +#### Example + +```ruby +require 'VoucherifySdk' + +VoucherifySdk::VouchersRedemptionGetResponseBodyRedemptionEntriesItem.build(data) +# => # + +VoucherifySdk::VouchersRedemptionGetResponseBodyRedemptionEntriesItem.build(data_that_doesnt_match) +# => nil +``` + +#### Parameters + +| Name | Type | Description | +| ---- | ---- | ----------- | +| **data** | **Mixed** | data to be matched against the list of oneOf items | + +#### Return type + +- `Redemption` +- `RedemptionRollback` +- `nil` (if no type matches) + diff --git a/docs/VouchersTransactionsExportCreateRequestBody.md b/docs/VouchersTransactionsExportCreateRequestBody.md new file mode 100644 index 00000000..146a3e10 --- /dev/null +++ b/docs/VouchersTransactionsExportCreateRequestBody.md @@ -0,0 +1,8 @@ +# VoucherifySdk::VouchersTransactionsExportCreateRequestBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **parameters** | [**VoucherTransactionsExportParameters**](VoucherTransactionsExportParameters.md) | | [optional] | + diff --git a/docs/VouchersTransactionsExportCreateResponseBody.md b/docs/VouchersTransactionsExportCreateResponseBody.md new file mode 100644 index 00000000..3f0b0046 --- /dev/null +++ b/docs/VouchersTransactionsExportCreateResponseBody.md @@ -0,0 +1,16 @@ +# VoucherifySdk::VouchersTransactionsExportCreateResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique export ID. | | +| **object** | **String** | The type of object being represented. This object stores information about the `export`. | [default to 'export'] | +| **created_at** | **Time** | Timestamp representing the date and time when the export was scheduled in ISO 8601 format. | | +| **status** | **String** | Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. | [default to 'SCHEDULED'] | +| **channel** | **String** | The channel through which the export was triggered. | [default to 'API'] | +| **exported_object** | **String** | The type of exported object. | [default to 'voucher_transactions'] | +| **parameters** | [**VoucherTransactionsFilters**](VoucherTransactionsFilters.md) | | | +| **result** | [**VoucherTransactionsExportResult**](VoucherTransactionsExportResult.md) | | | +| **user_id** | **String** | Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the `channel` value is `WEBSITE`. | | + diff --git a/docs/VouchersTransactionsListResponseBody.md b/docs/VouchersTransactionsListResponseBody.md new file mode 100644 index 00000000..2e04b8b5 --- /dev/null +++ b/docs/VouchersTransactionsListResponseBody.md @@ -0,0 +1,11 @@ +# VoucherifySdk::VouchersTransactionsListResponseBody + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **object** | **String** | The type of object represented by JSON. | [default to 'list'] | +| **data_ref** | **String** | Identifies the name of the attribute that contains the array of transaction objects. | [default to 'data'] | +| **data** | [**Array<VoucherTransaction>**](VoucherTransaction.md) | A dictionary that contains an array of transactions. Each entry in the array is a separate transaction object. | | +| **has_more** | **Boolean** | As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. | | + diff --git a/example.rb b/example.rb new file mode 100644 index 00000000..3457e923 --- /dev/null +++ b/example.rb @@ -0,0 +1,25 @@ +# Load the gem +require 'VoucherifySdk' + +# Setup authorization +VoucherifySdk.configure do |config| + # Configure API key authorization: X-App-Id + config.api_key['X-App-Id'] = 'YOUR API KEY' + + # Configure API key authorization: X-App-Token + config.api_key['X-App-Token'] = 'YOUR API KEY' + + # (Optional) Configure Voucherify cluster, default is https://api.voucherify.io + # config.host = 'https://us1.api.voucherify.io' +end + +# Creating API Instance +api_instance = VoucherifySdk::CampaignsApi.new + +# Calling list_campaigns +begin + result = api_instance.list_campaigns() + puts result +rescue VoucherifySdk::ApiError => e + puts "Exception when calling VouchersApi->list_campaigns: #{e}" +end diff --git a/examples/customers.rb b/examples/customers.rb deleted file mode 100644 index 89fea270..00000000 --- a/examples/customers.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'voucherify' - -voucherify = Voucherify::Client.new({ - :applicationId => 'c70a6f00-cf91-4756-9df5-47628850002b', - :clientSecretKey => '3266b9f8-e246-4f79-bdf0-833929b1380c' - }) - -new_customer = voucherify.customers.create({ - name: 'John Doe', - email: 'john@email.com', - description: 'Sample description about customer', - metadata: { - lang: 'en' - } - }) - -puts 'Created Customer:' -puts new_customer - -customer = voucherify.customers.get new_customer['id'] - -puts 'Retrieved Customer:' -puts customer - -customer[:description] = 'Sample description of customer with updates' - -updated_customer = voucherify.customers.update customer - -puts 'Updated Customer:' -puts updated_customer - -voucherify.customers.delete updated_customer['id'] diff --git a/examples/utils.rb b/examples/utils.rb deleted file mode 100644 index cfe1aa95..00000000 --- a/examples/utils.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'voucherify/utils' - -base_price = 20.00 - -puts 'base price: ' + base_price.to_s - -puts '===== amount discount =====' -amount_voucher = { - discount: { - amount_off: 1000, # 10.0 - type: 'AMOUNT' - } -} -puts 'discount: ' + Voucherify::Utils.calculate_discount(base_price, amount_voucher).to_s -puts 'price after discount: ' + Voucherify::Utils.calculate_price(base_price, amount_voucher).to_s -puts - - -puts '===== percent discount ====' - -percent_discount_voucher = { - discount: { - percent_off: 20, - type: 'PERCENT' - } -} - -puts 'discount: ' + Voucherify::Utils.calculate_discount(base_price, percent_discount_voucher).to_s -puts 'price after discount: ' + Voucherify::Utils.calculate_price(base_price, percent_discount_voucher).to_s -puts - - -puts '===== unit discount =======' - -unit_discount_voucher = { - discount: { - unit_off: 2, - type: 'UNIT' - } -} - -puts 'discount: ' + Voucherify::Utils.calculate_discount(base_price, unit_discount_voucher, 5).to_s -puts 'price after discount: ' + Voucherify::Utils.calculate_price(base_price, unit_discount_voucher, 5).to_s -puts - - -puts '===== gift voucher ========' - -gift_voucher = { - gift: { - amount: 1000, - balance: 500 - } -} - -puts 'discount: ' + Voucherify::Utils.calculate_discount(base_price, gift_voucher).to_s -puts 'price after discount: ' + Voucherify::Utils.calculate_price(base_price, gift_voucher).to_s -puts - -puts '===== gift voucher 2 ======' - -gift_voucher2 = { - gift: { - amount: 10000, - balance: 5000 - } -} - -puts 'discount: ' + Voucherify::Utils.calculate_discount(base_price, gift_voucher2).to_s -puts 'price after discount: ' + Voucherify::Utils.calculate_price(base_price, gift_voucher2).to_s -puts \ No newline at end of file diff --git a/examples/vouchers.rb b/examples/vouchers.rb deleted file mode 100644 index 88169442..00000000 --- a/examples/vouchers.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'voucherify' - -voucherify = Voucherify::Client.new({ - :applicationId => 'c70a6f00-cf91-4756-9df5-47628850002b', - :clientSecretKey => '3266b9f8-e246-4f79-bdf0-833929b1380c' - }) -begin - puts voucherify.validations.validate_voucher('91Ft4U', { - tracking_id: 'john@lemon.com', - order: { - amount: 1000 - } - }) -rescue Voucherify::VoucherifyError => e - puts e.message - puts e.details - puts e.key -end - -query = {limit: 10, skip: 20, category: 'API Test'} -puts voucherify.vouchers.list(query) - -puts voucherify.vouchers.enable '91Ft4U' - -puts voucherify.vouchers.disable '91Ft4U' \ No newline at end of file diff --git a/lib/VoucherifySdk.rb b/lib/VoucherifySdk.rb new file mode 100644 index 00000000..a5cba275 --- /dev/null +++ b/lib/VoucherifySdk.rb @@ -0,0 +1,716 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +# Common files +require 'VoucherifySdk/api_client' +require 'VoucherifySdk/api_error' +require 'VoucherifySdk/version' +require 'VoucherifySdk/configuration' + +# Models +require 'VoucherifySdk/models/any' +require 'VoucherifySdk/models/applicable_to' +require 'VoucherifySdk/models/applicable_to_effect' +require 'VoucherifySdk/models/applicable_to_result_list' +require 'VoucherifySdk/models/array_inner' +require 'VoucherifySdk/models/async_actions' +require 'VoucherifySdk/models/bus_val_rule_assignment' +require 'VoucherifySdk/models/campaign' +require 'VoucherifySdk/models/campaign_base' +require 'VoucherifySdk/models/campaign_base_validity_timeframe' +require 'VoucherifySdk/models/campaign_loyalty_card' +require 'VoucherifySdk/models/campaign_loyalty_card_expiration_rules' +require 'VoucherifySdk/models/campaign_loyalty_voucher' +require 'VoucherifySdk/models/campaign_loyalty_voucher_redemption' +require 'VoucherifySdk/models/campaign_voucher' +require 'VoucherifySdk/models/campaign_voucher_redemption' +require 'VoucherifySdk/models/campaigns_create_base' +require 'VoucherifySdk/models/campaigns_create_discount_coupons_campaign' +require 'VoucherifySdk/models/campaigns_create_gift_campaign' +require 'VoucherifySdk/models/campaigns_create_giveaway_campaign' +require 'VoucherifySdk/models/campaigns_create_loyalty_campaign' +require 'VoucherifySdk/models/campaigns_create_promotion_campaign' +require 'VoucherifySdk/models/campaigns_create_referral_campaign' +require 'VoucherifySdk/models/campaigns_create_request_body' +require 'VoucherifySdk/models/campaigns_create_response_body' +require 'VoucherifySdk/models/campaigns_delete_response_body' +require 'VoucherifySdk/models/campaigns_disable_response_body' +require 'VoucherifySdk/models/campaigns_enable_response_body' +require 'VoucherifySdk/models/campaigns_get_response_body' +require 'VoucherifySdk/models/campaigns_import_create_response_body' +require 'VoucherifySdk/models/campaigns_import_csv_create_response_body' +require 'VoucherifySdk/models/campaigns_import_voucher_item' +require 'VoucherifySdk/models/campaigns_import_voucher_item_redemption' +require 'VoucherifySdk/models/campaigns_import_voucher_loyalty_card' +require 'VoucherifySdk/models/campaigns_list_response_body' +require 'VoucherifySdk/models/campaigns_update_base' +require 'VoucherifySdk/models/campaigns_update_coupon_campaign_base' +require 'VoucherifySdk/models/campaigns_update_discount_coupons_campaign' +require 'VoucherifySdk/models/campaigns_update_gift_campaign' +require 'VoucherifySdk/models/campaigns_update_giveaway_campaign' +require 'VoucherifySdk/models/campaigns_update_loyalty_campaign' +require 'VoucherifySdk/models/campaigns_update_promotion_campaign' +require 'VoucherifySdk/models/campaigns_update_referral_campaign' +require 'VoucherifySdk/models/campaigns_update_request_body' +require 'VoucherifySdk/models/campaigns_update_response_body' +require 'VoucherifySdk/models/campaigns_vouchers_create_base_request_body' +require 'VoucherifySdk/models/campaigns_vouchers_create_in_bulk_request_body' +require 'VoucherifySdk/models/campaigns_vouchers_create_in_bulk_response_body' +require 'VoucherifySdk/models/campaigns_vouchers_create_request_body' +require 'VoucherifySdk/models/campaigns_vouchers_create_response_body' +require 'VoucherifySdk/models/categories_create_request_body' +require 'VoucherifySdk/models/categories_create_response_body' +require 'VoucherifySdk/models/categories_get_response_body' +require 'VoucherifySdk/models/categories_list_response_body' +require 'VoucherifySdk/models/categories_update_request_body' +require 'VoucherifySdk/models/categories_update_response_body' +require 'VoucherifySdk/models/category' +require 'VoucherifySdk/models/client_events_create_request_body' +require 'VoucherifySdk/models/client_events_create_request_body_loyalty' +require 'VoucherifySdk/models/client_events_create_request_body_referral' +require 'VoucherifySdk/models/client_events_create_response_body' +require 'VoucherifySdk/models/client_qualifications_check_eligibility_request_body' +require 'VoucherifySdk/models/client_qualifications_check_eligibility_response_body' +require 'VoucherifySdk/models/client_redemptions_redeem_request_body' +require 'VoucherifySdk/models/client_redemptions_redeem_request_body_all_of_options' +require 'VoucherifySdk/models/client_redemptions_redeem_response_body' +require 'VoucherifySdk/models/client_validations_validate_request_body' +require 'VoucherifySdk/models/client_validations_validate_request_body_all_of_options' +require 'VoucherifySdk/models/client_validations_validate_response_body' +require 'VoucherifySdk/models/code_config' +require 'VoucherifySdk/models/code_config_required_length_charset_pattern' +require 'VoucherifySdk/models/create_publication_base' +require 'VoucherifySdk/models/create_publication_campaign' +require 'VoucherifySdk/models/create_publication_with_campaign' +require 'VoucherifySdk/models/create_publication_with_specific_voucher' +require 'VoucherifySdk/models/custom_event' +require 'VoucherifySdk/models/custom_event_referral' +require 'VoucherifySdk/models/customer' +require 'VoucherifySdk/models/customer_activity' +require 'VoucherifySdk/models/customer_activity_data' +require 'VoucherifySdk/models/customer_base' +require 'VoucherifySdk/models/customer_base_address' +require 'VoucherifySdk/models/customer_id' +require 'VoucherifySdk/models/customer_loyalty' +require 'VoucherifySdk/models/customer_loyalty_campaigns_value' +require 'VoucherifySdk/models/customer_referrals' +require 'VoucherifySdk/models/customer_referrals_campaigns_item' +require 'VoucherifySdk/models/customer_response_data_assets' +require 'VoucherifySdk/models/customer_segments_list' +require 'VoucherifySdk/models/customer_summary' +require 'VoucherifySdk/models/customer_summary_orders' +require 'VoucherifySdk/models/customer_summary_redemptions' +require 'VoucherifySdk/models/customer_summary_redemptions_gift' +require 'VoucherifySdk/models/customer_summary_redemptions_loyalty_card' +require 'VoucherifySdk/models/customer_with_summary_loyalty_referrals' +require 'VoucherifySdk/models/customers_activities_list_response_body' +require 'VoucherifySdk/models/customers_create_request_body' +require 'VoucherifySdk/models/customers_create_response_body' +require 'VoucherifySdk/models/customers_get_response_body' +require 'VoucherifySdk/models/customers_import_csv_create_response_body' +require 'VoucherifySdk/models/customers_list_response_body' +require 'VoucherifySdk/models/customers_metadata_update_in_bulk_request_body' +require 'VoucherifySdk/models/customers_metadata_update_in_bulk_response_body' +require 'VoucherifySdk/models/customers_permanent_deletion_create_response_body' +require 'VoucherifySdk/models/customers_permanent_deletion_create_response_body_data_json' +require 'VoucherifySdk/models/customers_segments_list_response_body' +require 'VoucherifySdk/models/customers_update_in_bulk_request_body' +require 'VoucherifySdk/models/customers_update_in_bulk_response_body' +require 'VoucherifySdk/models/customers_update_request_body' +require 'VoucherifySdk/models/customers_update_response_body' +require 'VoucherifySdk/models/discount' +require 'VoucherifySdk/models/discount_amount' +require 'VoucherifySdk/models/discount_amount_vouchers_effect_types' +require 'VoucherifySdk/models/discount_coupons_campaign_voucher' +require 'VoucherifySdk/models/discount_fixed' +require 'VoucherifySdk/models/discount_fixed_vouchers_effect_types' +require 'VoucherifySdk/models/discount_percent' +require 'VoucherifySdk/models/discount_percent_vouchers_effect_types' +require 'VoucherifySdk/models/discount_unit' +require 'VoucherifySdk/models/discount_unit_multiple' +require 'VoucherifySdk/models/discount_unit_multiple_one_unit' +require 'VoucherifySdk/models/discount_unit_vouchers_effect_types' +require 'VoucherifySdk/models/earning_rule' +require 'VoucherifySdk/models/earning_rule_base' +require 'VoucherifySdk/models/earning_rule_base_custom_event' +require 'VoucherifySdk/models/earning_rule_base_loyalty' +require 'VoucherifySdk/models/earning_rule_base_segment' +require 'VoucherifySdk/models/earning_rule_base_source' +require 'VoucherifySdk/models/earning_rule_base_validity_timeframe' +require 'VoucherifySdk/models/earning_rule_event' +require 'VoucherifySdk/models/earning_rule_fixed' +require 'VoucherifySdk/models/earning_rule_proportional' +require 'VoucherifySdk/models/earning_rule_proportional_custom_event' +require 'VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event' +require 'VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event_metadata' +require 'VoucherifySdk/models/earning_rule_proportional_customer_metadata' +require 'VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer' +require 'VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer_metadata' +require 'VoucherifySdk/models/earning_rule_proportional_order' +require 'VoucherifySdk/models/earning_rule_proportional_order_amount' +require 'VoucherifySdk/models/earning_rule_proportional_order_amount_order' +require 'VoucherifySdk/models/earning_rule_proportional_order_amount_order_amount' +require 'VoucherifySdk/models/earning_rule_proportional_order_items' +require 'VoucherifySdk/models/earning_rule_proportional_order_items_amount' +require 'VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items' +require 'VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items_amount' +require 'VoucherifySdk/models/earning_rule_proportional_order_items_quantity' +require 'VoucherifySdk/models/earning_rule_proportional_order_items_quantity_order_items' +require 'VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount' +require 'VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount_order_items' +require 'VoucherifySdk/models/earning_rule_proportional_order_metadata' +require 'VoucherifySdk/models/earning_rule_proportional_order_metadata_order' +require 'VoucherifySdk/models/earning_rule_proportional_order_metadata_order_metadata' +require 'VoucherifySdk/models/earning_rule_proportional_order_total_amount' +require 'VoucherifySdk/models/earning_rule_proportional_order_total_amount_order' +require 'VoucherifySdk/models/error' +require 'VoucherifySdk/models/event_customer_active_campaign_failed' +require 'VoucherifySdk/models/event_customer_active_campaign_recovered' +require 'VoucherifySdk/models/event_customer_active_campaign_sent' +require 'VoucherifySdk/models/event_customer_batch_failed' +require 'VoucherifySdk/models/event_customer_batch_recovered' +require 'VoucherifySdk/models/event_customer_batch_sent' +require 'VoucherifySdk/models/event_customer_braze_failed' +require 'VoucherifySdk/models/event_customer_braze_recovered' +require 'VoucherifySdk/models/event_customer_braze_sent' +require 'VoucherifySdk/models/event_customer_confirmed' +require 'VoucherifySdk/models/event_customer_confirmed_unconfirmed_customer' +require 'VoucherifySdk/models/event_customer_consents' +require 'VoucherifySdk/models/event_customer_consents_given' +require 'VoucherifySdk/models/event_customer_consents_revoked' +require 'VoucherifySdk/models/event_customer_created' +require 'VoucherifySdk/models/event_customer_custom_event' +require 'VoucherifySdk/models/event_customer_deleted' +require 'VoucherifySdk/models/event_customer_email_failed' +require 'VoucherifySdk/models/event_customer_email_recovered' +require 'VoucherifySdk/models/event_customer_email_sent' +require 'VoucherifySdk/models/event_customer_failed' +require 'VoucherifySdk/models/event_customer_gift_voucher_balance_added' +require 'VoucherifySdk/models/event_customer_intercom_failed' +require 'VoucherifySdk/models/event_customer_intercom_recovered' +require 'VoucherifySdk/models/event_customer_intercom_sent' +require 'VoucherifySdk/models/event_customer_klaviyo_failed' +require 'VoucherifySdk/models/event_customer_klaviyo_recovered' +require 'VoucherifySdk/models/event_customer_klaviyo_sent' +require 'VoucherifySdk/models/event_customer_loyalty_card_points_added' +require 'VoucherifySdk/models/event_customer_loyalty_card_points_transferred' +require 'VoucherifySdk/models/event_customer_loyalty_tier_base' +require 'VoucherifySdk/models/event_customer_loyalty_tier_downgraded' +require 'VoucherifySdk/models/event_customer_loyalty_tier_expiration_changed' +require 'VoucherifySdk/models/event_customer_loyalty_tier_joined' +require 'VoucherifySdk/models/event_customer_loyalty_tier_left' +require 'VoucherifySdk/models/event_customer_loyalty_tier_prolonged' +require 'VoucherifySdk/models/event_customer_loyalty_tier_upgraded' +require 'VoucherifySdk/models/event_customer_loyalty_updated' +require 'VoucherifySdk/models/event_customer_mailchimp_failed' +require 'VoucherifySdk/models/event_customer_mailchimp_recovered' +require 'VoucherifySdk/models/event_customer_mailchimp_sent' +require 'VoucherifySdk/models/event_customer_order' +require 'VoucherifySdk/models/event_customer_order_canceled' +require 'VoucherifySdk/models/event_customer_order_created' +require 'VoucherifySdk/models/event_customer_order_fulfilled' +require 'VoucherifySdk/models/event_customer_order_paid' +require 'VoucherifySdk/models/event_customer_order_processing' +require 'VoucherifySdk/models/event_customer_order_updated' +require 'VoucherifySdk/models/event_customer_publication_failed' +require 'VoucherifySdk/models/event_customer_publication_succeeded' +require 'VoucherifySdk/models/event_customer_recovered' +require 'VoucherifySdk/models/event_customer_redemption' +require 'VoucherifySdk/models/event_customer_redemption_failed' +require 'VoucherifySdk/models/event_customer_redemption_rollback_failed' +require 'VoucherifySdk/models/event_customer_redemption_rollback_succeeded' +require 'VoucherifySdk/models/event_customer_redemption_succeeded' +require 'VoucherifySdk/models/event_customer_referred' +require 'VoucherifySdk/models/event_customer_reward_redemptions' +require 'VoucherifySdk/models/event_customer_reward_redemptions_completed' +require 'VoucherifySdk/models/event_customer_reward_redemptions_created' +require 'VoucherifySdk/models/event_customer_reward_redemptions_pending' +require 'VoucherifySdk/models/event_customer_reward_redemptions_rolled_back' +require 'VoucherifySdk/models/event_customer_rewarded' +require 'VoucherifySdk/models/event_customer_rewarded_loyalty_points' +require 'VoucherifySdk/models/event_customer_segment_entered' +require 'VoucherifySdk/models/event_customer_segment_left' +require 'VoucherifySdk/models/event_customer_sent' +require 'VoucherifySdk/models/event_customer_shopify_failed' +require 'VoucherifySdk/models/event_customer_shopify_recovered' +require 'VoucherifySdk/models/event_customer_shopify_sent' +require 'VoucherifySdk/models/event_customer_sms_failed' +require 'VoucherifySdk/models/event_customer_sms_recovered' +require 'VoucherifySdk/models/event_customer_sms_sent' +require 'VoucherifySdk/models/event_customer_updated' +require 'VoucherifySdk/models/event_customer_validation_failed' +require 'VoucherifySdk/models/event_customer_validation_succeeded' +require 'VoucherifySdk/models/event_customer_voucher_deleted' +require 'VoucherifySdk/models/event_customer_vouchers_loyalty_points_expired' +require 'VoucherifySdk/models/events_create_request_body' +require 'VoucherifySdk/models/events_create_response_body' +require 'VoucherifySdk/models/export' +require 'VoucherifySdk/models/export_base' +require 'VoucherifySdk/models/export_base_result' +require 'VoucherifySdk/models/export_customer' +require 'VoucherifySdk/models/export_customer_base' +require 'VoucherifySdk/models/export_customer_base_parameters' +require 'VoucherifySdk/models/export_customer_fields' +require 'VoucherifySdk/models/export_customer_order' +require 'VoucherifySdk/models/export_customer_scheduled' +require 'VoucherifySdk/models/export_order' +require 'VoucherifySdk/models/export_order_base' +require 'VoucherifySdk/models/export_order_fields' +require 'VoucherifySdk/models/export_order_order' +require 'VoucherifySdk/models/export_order_scheduled' +require 'VoucherifySdk/models/export_points_expiration' +require 'VoucherifySdk/models/export_points_expiration_base' +require 'VoucherifySdk/models/export_points_expiration_base_parameters' +require 'VoucherifySdk/models/export_points_expiration_fields' +require 'VoucherifySdk/models/export_points_expiration_filters' +require 'VoucherifySdk/models/export_points_expiration_order' +require 'VoucherifySdk/models/export_points_expiration_scheduled' +require 'VoucherifySdk/models/export_publication' +require 'VoucherifySdk/models/export_publication_base' +require 'VoucherifySdk/models/export_publication_base_parameters' +require 'VoucherifySdk/models/export_publication_fields' +require 'VoucherifySdk/models/export_publication_order' +require 'VoucherifySdk/models/export_publication_scheduled' +require 'VoucherifySdk/models/export_redemption' +require 'VoucherifySdk/models/export_redemption_base' +require 'VoucherifySdk/models/export_redemption_base_parameters' +require 'VoucherifySdk/models/export_redemption_fields' +require 'VoucherifySdk/models/export_redemption_order' +require 'VoucherifySdk/models/export_redemption_scheduled' +require 'VoucherifySdk/models/export_scheduled_base' +require 'VoucherifySdk/models/export_voucher' +require 'VoucherifySdk/models/export_voucher_base' +require 'VoucherifySdk/models/export_voucher_base_parameters' +require 'VoucherifySdk/models/export_voucher_fields' +require 'VoucherifySdk/models/export_voucher_order' +require 'VoucherifySdk/models/export_voucher_scheduled' +require 'VoucherifySdk/models/export_voucher_transactions' +require 'VoucherifySdk/models/export_voucher_transactions_base' +require 'VoucherifySdk/models/export_voucher_transactions_fields' +require 'VoucherifySdk/models/export_voucher_transactions_filters' +require 'VoucherifySdk/models/export_voucher_transactions_order' +require 'VoucherifySdk/models/export_voucher_transactions_scheduled' +require 'VoucherifySdk/models/exports_create_request_body' +require 'VoucherifySdk/models/exports_create_response_body' +require 'VoucherifySdk/models/exports_get_response_body' +require 'VoucherifySdk/models/exports_list_response_body' +require 'VoucherifySdk/models/field_conditions' +require 'VoucherifySdk/models/filter_conditions_string' +require 'VoucherifySdk/models/filters_condition' +require 'VoucherifySdk/models/gift' +require 'VoucherifySdk/models/gift_campaign_voucher' +require 'VoucherifySdk/models/giveaway_campaign_voucher' +require 'VoucherifySdk/models/inapplicable_to' +require 'VoucherifySdk/models/inapplicable_to_result_list' +require 'VoucherifySdk/models/junction' +require 'VoucherifySdk/models/list_publications_item_base' +require 'VoucherifySdk/models/list_publications_item_invalid' +require 'VoucherifySdk/models/list_publications_item_valid_multiple_vouchers' +require 'VoucherifySdk/models/list_publications_item_valid_single_voucher' +require 'VoucherifySdk/models/list_publications_item_voucher' +require 'VoucherifySdk/models/loyalties_delete_response_body' +require 'VoucherifySdk/models/loyalties_earning_rules_disable_response_body' +require 'VoucherifySdk/models/loyalties_earning_rules_enable_response_body' +require 'VoucherifySdk/models/loyalties_earning_rules_get_response_body' +require 'VoucherifySdk/models/loyalties_loyalty_tier_reward' +require 'VoucherifySdk/models/loyalties_members_balance_update_request_body' +require 'VoucherifySdk/models/loyalties_members_balance_update_response_body' +require 'VoucherifySdk/models/loyalties_members_balance_update_response_body_related_object' +require 'VoucherifySdk/models/loyalties_members_points_expiration_list_response_body' +require 'VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item' +require 'VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item_bucket' +require 'VoucherifySdk/models/loyalties_members_redemption_redeem_request_body' +require 'VoucherifySdk/models/loyalties_members_redemption_redeem_request_body_reward' +require 'VoucherifySdk/models/loyalties_members_redemption_redeem_response_body' +require 'VoucherifySdk/models/loyalties_members_rewards_list_response_body' +require 'VoucherifySdk/models/loyalties_members_rewards_list_response_body_data_item' +require 'VoucherifySdk/models/loyalties_members_tiers_list_response_body' +require 'VoucherifySdk/models/loyalties_members_transactions_export_create_request_body' +require 'VoucherifySdk/models/loyalties_members_transactions_export_create_request_body_parameters' +require 'VoucherifySdk/models/loyalties_members_transactions_export_create_response_body' +require 'VoucherifySdk/models/loyalties_members_transactions_list_response_body' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_barcode' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_qr' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body_loyalty_card' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body_publish' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body_redemption' +require 'VoucherifySdk/models/loyalties_members_transfers_create_response_body_validity_timeframe' +require 'VoucherifySdk/models/loyalties_reward_assignments_get_response_body' +require 'VoucherifySdk/models/loyalties_reward_assignments_reward_get_response_body' +require 'VoucherifySdk/models/loyalties_rewards_get_response_body' +require 'VoucherifySdk/models/loyalties_tiers_create_in_bulk_request_body_item' +require 'VoucherifySdk/models/loyalties_tiers_earning_rules_list_response_body' +require 'VoucherifySdk/models/loyalties_tiers_get_response_body' +require 'VoucherifySdk/models/loyalties_tiers_list_response_body' +require 'VoucherifySdk/models/loyalties_tiers_rewards_list_response_body' +require 'VoucherifySdk/models/loyalties_transfer_points' +require 'VoucherifySdk/models/loyalty_card_transaction' +require 'VoucherifySdk/models/loyalty_card_transactions_type' +require 'VoucherifySdk/models/loyalty_tier' +require 'VoucherifySdk/models/loyalty_tier_all_of_config' +require 'VoucherifySdk/models/loyalty_tier_all_of_config_points' +require 'VoucherifySdk/models/loyalty_tier_base' +require 'VoucherifySdk/models/loyalty_tier_base_points' +require 'VoucherifySdk/models/loyalty_tier_expiration' +require 'VoucherifySdk/models/loyalty_tiers_expiration_all' +require 'VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date' +require 'VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date_rounding' +require 'VoucherifySdk/models/loyalty_tiers_expiration_all_start_date' +require 'VoucherifySdk/models/lucky_draw' +require 'VoucherifySdk/models/mapping_fixed' +require 'VoucherifySdk/models/mapping_multiply' +require 'VoucherifySdk/models/mapping_points' +require 'VoucherifySdk/models/order' +require 'VoucherifySdk/models/order_base' +require 'VoucherifySdk/models/order_calculated' +require 'VoucherifySdk/models/order_calculated_base' +require 'VoucherifySdk/models/order_calculated_customer' +require 'VoucherifySdk/models/order_calculated_no_customer_data' +require 'VoucherifySdk/models/order_calculated_referrer' +require 'VoucherifySdk/models/order_item' +require 'VoucherifySdk/models/order_item_calculated' +require 'VoucherifySdk/models/order_item_product' +require 'VoucherifySdk/models/order_item_sku' +require 'VoucherifySdk/models/order_redemptions' +require 'VoucherifySdk/models/orders_create_request_body' +require 'VoucherifySdk/models/orders_create_response_body' +require 'VoucherifySdk/models/orders_export_create_request_body' +require 'VoucherifySdk/models/orders_export_create_request_body_parameters' +require 'VoucherifySdk/models/orders_export_create_response_body' +require 'VoucherifySdk/models/orders_get_response_body' +require 'VoucherifySdk/models/orders_import_create_request_body_item' +require 'VoucherifySdk/models/orders_import_create_response_body' +require 'VoucherifySdk/models/orders_list_response_body' +require 'VoucherifySdk/models/orders_update_request_body' +require 'VoucherifySdk/models/orders_update_response_body' +require 'VoucherifySdk/models/parameter_campaign_type' +require 'VoucherifySdk/models/parameter_created_before_after' +require 'VoucherifySdk/models/parameter_expand_list_campaigns' +require 'VoucherifySdk/models/parameter_filters_list_redemptions' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_campaign_name' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_customer_id' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_failure_code' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_object' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_parent_redemption_id' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_related_object_id' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_related_object_parent_id' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_result' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_user_login' +require 'VoucherifySdk/models/parameter_filters_list_redemptions_voucher_code' +require 'VoucherifySdk/models/parameter_order' +require 'VoucherifySdk/models/parameter_order_list_all_promotion_stacks' +require 'VoucherifySdk/models/parameter_order_list_campaigns' +require 'VoucherifySdk/models/parameter_order_list_customers' +require 'VoucherifySdk/models/parameter_order_list_exports' +require 'VoucherifySdk/models/parameter_order_list_loyalty_tiers' +require 'VoucherifySdk/models/parameter_order_list_orders' +require 'VoucherifySdk/models/parameter_order_list_publications' +require 'VoucherifySdk/models/parameter_order_list_redemptions' +require 'VoucherifySdk/models/parameter_order_list_validation_rule_assignments' +require 'VoucherifySdk/models/parameter_order_list_validation_rules' +require 'VoucherifySdk/models/parameter_result_list_publications' +require 'VoucherifySdk/models/parameter_updated_before_after' +require 'VoucherifySdk/models/parameter_voucher_type_list_publications' +require 'VoucherifySdk/models/points_expiration_types' +require 'VoucherifySdk/models/product' +require 'VoucherifySdk/models/product_collections_create_dynamic_request_body' +require 'VoucherifySdk/models/product_collections_create_dynamic_request_body_filter' +require 'VoucherifySdk/models/product_collections_create_dynamic_request_body_products_item' +require 'VoucherifySdk/models/product_collections_create_request_body' +require 'VoucherifySdk/models/product_collections_create_response_body' +require 'VoucherifySdk/models/product_collections_create_static_request_body' +require 'VoucherifySdk/models/product_collections_get_response_body' +require 'VoucherifySdk/models/product_collections_item' +require 'VoucherifySdk/models/product_collections_item_products_item' +require 'VoucherifySdk/models/product_collections_list' +require 'VoucherifySdk/models/product_collections_list_response_body' +require 'VoucherifySdk/models/product_collections_products_list' +require 'VoucherifySdk/models/product_collections_products_list_products_item' +require 'VoucherifySdk/models/product_collections_products_list_response_body' +require 'VoucherifySdk/models/product_without_skus' +require 'VoucherifySdk/models/products_create_request_body' +require 'VoucherifySdk/models/products_create_response_body' +require 'VoucherifySdk/models/products_get_response_body' +require 'VoucherifySdk/models/products_import_csv_create_response_body' +require 'VoucherifySdk/models/products_list_response_body' +require 'VoucherifySdk/models/products_metadata_update_in_bulk_request_body' +require 'VoucherifySdk/models/products_metadata_update_in_bulk_response_body' +require 'VoucherifySdk/models/products_skus_create_request_body' +require 'VoucherifySdk/models/products_skus_create_response_body' +require 'VoucherifySdk/models/products_skus_list_response_body' +require 'VoucherifySdk/models/products_skus_update_request_body' +require 'VoucherifySdk/models/products_skus_update_response_body' +require 'VoucherifySdk/models/products_update_in_bulk_request_body' +require 'VoucherifySdk/models/products_update_in_bulk_response_body' +require 'VoucherifySdk/models/products_update_request_body' +require 'VoucherifySdk/models/products_update_response_body' +require 'VoucherifySdk/models/promotion_stack' +require 'VoucherifySdk/models/promotion_stack_base' +require 'VoucherifySdk/models/promotion_stack_base_tiers' +require 'VoucherifySdk/models/promotion_tier' +require 'VoucherifySdk/models/promotion_tier_action' +require 'VoucherifySdk/models/promotion_tier_campaign' +require 'VoucherifySdk/models/promotion_tier_campaign_validity_timeframe' +require 'VoucherifySdk/models/promotion_tier_create_params' +require 'VoucherifySdk/models/promotion_tier_summary' +require 'VoucherifySdk/models/promotion_tier_summary_orders' +require 'VoucherifySdk/models/promotion_tier_summary_redemptions' +require 'VoucherifySdk/models/promotion_tier_validity_timeframe' +require 'VoucherifySdk/models/promotion_tiers_list' +require 'VoucherifySdk/models/promotions_stacks_create_request_body' +require 'VoucherifySdk/models/promotions_stacks_create_response_body' +require 'VoucherifySdk/models/promotions_stacks_get_response_body' +require 'VoucherifySdk/models/promotions_stacks_list_response_body' +require 'VoucherifySdk/models/promotions_stacks_update_request_body' +require 'VoucherifySdk/models/promotions_stacks_update_request_body_tiers' +require 'VoucherifySdk/models/promotions_stacks_update_response_body' +require 'VoucherifySdk/models/promotions_tiers_disable_response_body' +require 'VoucherifySdk/models/promotions_tiers_enable_response_body' +require 'VoucherifySdk/models/promotions_tiers_get_response_body' +require 'VoucherifySdk/models/promotions_tiers_list_response_body' +require 'VoucherifySdk/models/properties_for_loyalty_campaign_options' +require 'VoucherifySdk/models/publications_create_base_response_body' +require 'VoucherifySdk/models/publications_create_request_body' +require 'VoucherifySdk/models/publications_create_response_body' +require 'VoucherifySdk/models/publications_create_voucher_response_body' +require 'VoucherifySdk/models/publications_create_vouchers_response_body' +require 'VoucherifySdk/models/publications_list_response_body' +require 'VoucherifySdk/models/publications_list_response_body_publications_item' +require 'VoucherifySdk/models/qualifications_check_eligibility_request_body' +require 'VoucherifySdk/models/qualifications_check_eligibility_response_body' +require 'VoucherifySdk/models/qualifications_field_conditions' +require 'VoucherifySdk/models/qualifications_filters_condition' +require 'VoucherifySdk/models/qualifications_option' +require 'VoucherifySdk/models/qualifications_option_filters' +require 'VoucherifySdk/models/qualifications_option_filters_resource_type' +require 'VoucherifySdk/models/qualifications_option_filters_resource_type_conditions' +require 'VoucherifySdk/models/qualifications_redeemable' +require 'VoucherifySdk/models/qualifications_redeemable_base' +require 'VoucherifySdk/models/qualifications_redeemables' +require 'VoucherifySdk/models/redeem_gift_card' +require 'VoucherifySdk/models/redeem_gift_card_all_of_gift' +require 'VoucherifySdk/models/redeem_loyalty_card' +require 'VoucherifySdk/models/redeem_loyalty_card_all_of_reward' +require 'VoucherifySdk/models/redeem_promotion_stack' +require 'VoucherifySdk/models/redeem_promotion_tier' +require 'VoucherifySdk/models/redeem_voucher' +require 'VoucherifySdk/models/redeemable_gift' +require 'VoucherifySdk/models/redeemable_loyalty_card' +require 'VoucherifySdk/models/redeemable_result' +require 'VoucherifySdk/models/redeemable_result_gift_card' +require 'VoucherifySdk/models/redeemable_result_gift_card_gift' +require 'VoucherifySdk/models/redeemable_result_loyalty_card' +require 'VoucherifySdk/models/redeemable_result_loyalty_card_loyalty_card' +require 'VoucherifySdk/models/redeemable_result_promotion_stack' +require 'VoucherifySdk/models/redeemable_result_promotion_tier' +require 'VoucherifySdk/models/redeemable_result_promotion_tier_discount' +require 'VoucherifySdk/models/redeemable_result_voucher_code' +require 'VoucherifySdk/models/redemption' +require 'VoucherifySdk/models/redemption_channel' +require 'VoucherifySdk/models/redemption_gift' +require 'VoucherifySdk/models/redemption_internal' +require 'VoucherifySdk/models/redemption_internal_related_redemptions' +require 'VoucherifySdk/models/redemption_internal_related_redemptions_item' +require 'VoucherifySdk/models/redemption_internal_related_redemptions_rollbacks_item' +require 'VoucherifySdk/models/redemption_loyalty_card' +require 'VoucherifySdk/models/redemption_related_redemptions' +require 'VoucherifySdk/models/redemption_related_redemptions_item' +require 'VoucherifySdk/models/redemption_related_redemptions_rollbacks_item' +require 'VoucherifySdk/models/redemption_reward_result' +require 'VoucherifySdk/models/redemption_reward_result_parameters' +require 'VoucherifySdk/models/redemption_reward_result_parameters_campaign' +require 'VoucherifySdk/models/redemption_reward_result_parameters_coin' +require 'VoucherifySdk/models/redemption_reward_result_parameters_product' +require 'VoucherifySdk/models/redemption_reward_result_product' +require 'VoucherifySdk/models/redemption_reward_result_sku' +require 'VoucherifySdk/models/redemption_reward_result_voucher' +require 'VoucherifySdk/models/redemption_rollback' +require 'VoucherifySdk/models/redemption_rollback_related_redemptions' +require 'VoucherifySdk/models/redemption_rollback_related_redemptions_item' +require 'VoucherifySdk/models/redemption_rollback_related_redemptions_rollbacks_item' +require 'VoucherifySdk/models/redemptions_get_response_body' +require 'VoucherifySdk/models/redemptions_list_response_body' +require 'VoucherifySdk/models/redemptions_list_response_body_redemptions_item' +require 'VoucherifySdk/models/redemptions_redeem_request_body' +require 'VoucherifySdk/models/redemptions_redeem_response_body' +require 'VoucherifySdk/models/redemptions_rollback_create_request_body' +require 'VoucherifySdk/models/redemptions_rollback_create_response_body' +require 'VoucherifySdk/models/redemptions_rollbacks_create_request_body' +require 'VoucherifySdk/models/redemptions_rollbacks_create_response_body' +require 'VoucherifySdk/models/referral_campaign_voucher' +require 'VoucherifySdk/models/referral_program' +require 'VoucherifySdk/models/referral_program_custom_event' +require 'VoucherifySdk/models/referral_program_referee_reward' +require 'VoucherifySdk/models/referral_program_referee_reward_related_object_parent' +require 'VoucherifySdk/models/referrer' +require 'VoucherifySdk/models/referrer_id' +require 'VoucherifySdk/models/referrer_with_summary_loyalty_referrals' +require 'VoucherifySdk/models/resource_types' +require 'VoucherifySdk/models/reward' +require 'VoucherifySdk/models/reward_assignment' +require 'VoucherifySdk/models/reward_assignment_base' +require 'VoucherifySdk/models/reward_assignment_parameters' +require 'VoucherifySdk/models/reward_assignment_parameters_parameters' +require 'VoucherifySdk/models/reward_assignment_parameters_parameters_loyalty' +require 'VoucherifySdk/models/reward_assignments_create_coin_reward_request_body' +require 'VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body' +require 'VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters' +require 'VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters_loyalty' +require 'VoucherifySdk/models/reward_attributes' +require 'VoucherifySdk/models/reward_type' +require 'VoucherifySdk/models/reward_type_campaign' +require 'VoucherifySdk/models/reward_type_campaign_campaign' +require 'VoucherifySdk/models/reward_type_coin' +require 'VoucherifySdk/models/reward_type_coin_coin' +require 'VoucherifySdk/models/reward_type_material' +require 'VoucherifySdk/models/reward_type_material_product' +require 'VoucherifySdk/models/rewards_assignments_create_request_body' +require 'VoucherifySdk/models/rewards_assignments_create_response_body' +require 'VoucherifySdk/models/rewards_assignments_get_response_body' +require 'VoucherifySdk/models/rewards_assignments_list_response_body' +require 'VoucherifySdk/models/rewards_assignments_update_request_body' +require 'VoucherifySdk/models/rewards_assignments_update_request_body_parameters' +require 'VoucherifySdk/models/rewards_assignments_update_request_body_parameters_loyalty' +require 'VoucherifySdk/models/rewards_assignments_update_response_body' +require 'VoucherifySdk/models/schema_that_contains_unique_properties_for_promotion_campaign_promotion' +require 'VoucherifySdk/models/session' +require 'VoucherifySdk/models/simple_campaign' +require 'VoucherifySdk/models/simple_consent' +require 'VoucherifySdk/models/simple_customer' +require 'VoucherifySdk/models/simple_customer_required_object_type' +require 'VoucherifySdk/models/simple_order' +require 'VoucherifySdk/models/simple_order_item' +require 'VoucherifySdk/models/simple_product' +require 'VoucherifySdk/models/simple_product_discount_unit' +require 'VoucherifySdk/models/simple_promotion_tier' +require 'VoucherifySdk/models/simple_promotion_tier_campaign' +require 'VoucherifySdk/models/simple_redemption' +require 'VoucherifySdk/models/simple_redemption_reward_result' +require 'VoucherifySdk/models/simple_referral_tier' +require 'VoucherifySdk/models/simple_segment' +require 'VoucherifySdk/models/simple_sku' +require 'VoucherifySdk/models/simple_sku_discount_unit' +require 'VoucherifySdk/models/simple_voucher' +require 'VoucherifySdk/models/sku' +require 'VoucherifySdk/models/sku_with_product' +require 'VoucherifySdk/models/skus_get_response_body' +require 'VoucherifySdk/models/skus_import_csv_create_response_body' +require 'VoucherifySdk/models/skus_list' +require 'VoucherifySdk/models/skus_list_for_product' +require 'VoucherifySdk/models/stackable_validate_redeem_base' +require 'VoucherifySdk/models/stackable_validate_redeem_base_redeemables_item' +require 'VoucherifySdk/models/stacking_rules' +require 'VoucherifySdk/models/validation_entity' +require 'VoucherifySdk/models/validation_rule' +require 'VoucherifySdk/models/validation_rule_assignment' +require 'VoucherifySdk/models/validation_rule_assignments_list' +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_list' +require 'VoucherifySdk/models/validation_rules_assignments_list_response_body' +require 'VoucherifySdk/models/validation_rules_create_request_body' +require 'VoucherifySdk/models/validation_rules_create_response_body' +require 'VoucherifySdk/models/validation_rules_get_response_body' +require 'VoucherifySdk/models/validation_rules_list_response_body' +require 'VoucherifySdk/models/validation_rules_update_request_body' +require 'VoucherifySdk/models/validation_rules_update_response_body' +require 'VoucherifySdk/models/validations_redeemable_applicable' +require 'VoucherifySdk/models/validations_redeemable_applicable_result' +require 'VoucherifySdk/models/validations_redeemable_inapplicable' +require 'VoucherifySdk/models/validations_redeemable_inapplicable_result' +require 'VoucherifySdk/models/validations_redeemable_skipped' +require 'VoucherifySdk/models/validations_validate_all_response_body_redeemables_item' +require 'VoucherifySdk/models/validations_validate_request_body' +require 'VoucherifySdk/models/validations_validate_response_body' +require 'VoucherifySdk/models/voucher' +require 'VoucherifySdk/models/voucher_assets' +require 'VoucherifySdk/models/voucher_gift' +require 'VoucherifySdk/models/voucher_loyalty_card' +require 'VoucherifySdk/models/voucher_publish' +require 'VoucherifySdk/models/voucher_redemption' +require 'VoucherifySdk/models/voucher_transaction' +require 'VoucherifySdk/models/voucher_transaction_details' +require 'VoucherifySdk/models/voucher_transaction_details_balance' +require 'VoucherifySdk/models/voucher_transaction_details_balance_related_object' +require 'VoucherifySdk/models/voucher_transaction_details_custom_event' +require 'VoucherifySdk/models/voucher_transaction_details_earning_rule' +require 'VoucherifySdk/models/voucher_transaction_details_earning_rule_source' +require 'VoucherifySdk/models/voucher_transaction_details_event' +require 'VoucherifySdk/models/voucher_transaction_details_event_schema' +require 'VoucherifySdk/models/voucher_transaction_details_loyalty_tier' +require 'VoucherifySdk/models/voucher_transaction_details_order' +require 'VoucherifySdk/models/voucher_transaction_details_redemption' +require 'VoucherifySdk/models/voucher_transaction_details_reward' +require 'VoucherifySdk/models/voucher_transaction_details_rollback' +require 'VoucherifySdk/models/voucher_transaction_details_segment' +require 'VoucherifySdk/models/voucher_transactions_export' +require 'VoucherifySdk/models/voucher_transactions_export_filter_conditions' +require 'VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id' +require 'VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id_conditions' +require 'VoucherifySdk/models/voucher_transactions_export_parameters' +require 'VoucherifySdk/models/voucher_transactions_export_result' +require 'VoucherifySdk/models/voucher_transactions_filters' +require 'VoucherifySdk/models/voucher_validity_timeframe' +require 'VoucherifySdk/models/vouchers_balance_update_request_body' +require 'VoucherifySdk/models/vouchers_balance_update_response_body' +require 'VoucherifySdk/models/vouchers_balance_update_response_body_related_object' +require 'VoucherifySdk/models/vouchers_disable_response_body' +require 'VoucherifySdk/models/vouchers_enable_response_body' +require 'VoucherifySdk/models/vouchers_get_response_body' +require 'VoucherifySdk/models/vouchers_import_csv_create_response_body' +require 'VoucherifySdk/models/vouchers_redemption_get_response_body' +require 'VoucherifySdk/models/vouchers_redemption_get_response_body_redemption_entries_item' +require 'VoucherifySdk/models/vouchers_transactions_export_create_request_body' +require 'VoucherifySdk/models/vouchers_transactions_export_create_response_body' +require 'VoucherifySdk/models/vouchers_transactions_list_response_body' + +# APIs +require 'VoucherifySdk/api/campaigns_api' +require 'VoucherifySdk/api/categories_api' +require 'VoucherifySdk/api/client_side_api' +require 'VoucherifySdk/api/customers_api' +require 'VoucherifySdk/api/events_api' +require 'VoucherifySdk/api/exports_api' +require 'VoucherifySdk/api/loyalties_api' +require 'VoucherifySdk/api/orders_api' +require 'VoucherifySdk/api/product_collections_api' +require 'VoucherifySdk/api/products_api' +require 'VoucherifySdk/api/promotions_api' +require 'VoucherifySdk/api/publications_api' +require 'VoucherifySdk/api/qualifications_api' +require 'VoucherifySdk/api/redemptions_api' +require 'VoucherifySdk/api/rewards_api' +require 'VoucherifySdk/api/segments_api' +require 'VoucherifySdk/api/validation_rules_api' +require 'VoucherifySdk/api/validations_api' +require 'VoucherifySdk/api/vouchers_api' + +module VoucherifySdk + class << self + # Customize default settings for the SDK using block. + # VoucherifySdk.configure do |config| + # config.username = "xxx" + # config.password = "xxx" + # end + # If no block given, return the default Configuration object. + def configure + if block_given? + yield(Configuration.default) + else + Configuration.default + end + end + end +end diff --git a/lib/VoucherifySdk/api/campaigns_api.rb b/lib/VoucherifySdk/api/campaigns_api.rb new file mode 100644 index 00000000..2cb2d0c3 --- /dev/null +++ b/lib/VoucherifySdk/api/campaigns_api.rb @@ -0,0 +1,789 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class CampaignsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Add Voucher with Specific Code to Campaign + # This method gives a possibility to add a new voucher to an existing campaign. The voucher definition will be inherited from the definition kept in the campaign profile. However, you are able to overwrite a few properties inherited from the campaign. + # @param campaign_id [String] The campaign ID or name of the campaign to which voucher will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param code [String] A custom **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @option opts [CampaignsVouchersCreateRequestBody] :campaigns_vouchers_create_request_body Specify the voucher parameters that you would like to overwrite. + # @return [CampaignsVouchersCreateResponseBody] + def add_voucher_with_specific_code_to_campaign(campaign_id, code, opts = {}) + data, _status_code, _headers = add_voucher_with_specific_code_to_campaign_with_http_info(campaign_id, code, opts) + data + end + + # Add Voucher with Specific Code to Campaign + # This method gives a possibility to add a new voucher to an existing campaign. The voucher definition will be inherited from the definition kept in the campaign profile. However, you are able to overwrite a few properties inherited from the campaign. + # @param campaign_id [String] The campaign ID or name of the campaign to which voucher will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param code [String] A custom **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @option opts [CampaignsVouchersCreateRequestBody] :campaigns_vouchers_create_request_body Specify the voucher parameters that you would like to overwrite. + # @return [Array<(CampaignsVouchersCreateResponseBody, Integer, Hash)>] CampaignsVouchersCreateResponseBody data, response status code and response headers + private def add_voucher_with_specific_code_to_campaign_with_http_info(campaign_id, code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.add_voucher_with_specific_code_to_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.add_voucher_with_specific_code_to_campaign" + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling CampaignsApi.add_voucher_with_specific_code_to_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}/vouchers/{code}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'campaigns_vouchers_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsVouchersCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.add_voucher_with_specific_code_to_campaign", + :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: CampaignsApi#add_voucher_with_specific_code_to_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Add Vouchers to Campaign + # This method gives the possibility to push new vouchers to an existing campaign. New vouchers will inherit properties from the campaign profile. However, it is possible to overwrite some of them in the request body. If you provide an optional code_config parameter with a voucher code configuration, then it will be used to generate new voucher codes. Otherwise, the voucher code configuration from the campaign will be used. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] The campaign ID or name of the campaign to which voucher(s) will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :vouchers_count Number of vouchers that should be added. + # @option opts [CampaignsVouchersCreateInBulkRequestBody] :campaigns_vouchers_create_in_bulk_request_body Specify the voucher parameters that you would like to overwrite. + # @return [CampaignsVouchersCreateResponseBody] + def add_vouchers_to_campaign(campaign_id, opts = {}) + data, _status_code, _headers = add_vouchers_to_campaign_with_http_info(campaign_id, opts) + data + end + + # Add Vouchers to Campaign + # This method gives the possibility to push new vouchers to an existing campaign. New vouchers will inherit properties from the campaign profile. However, it is possible to overwrite some of them in the request body. If you provide an optional code_config parameter with a voucher code configuration, then it will be used to generate new voucher codes. Otherwise, the voucher code configuration from the campaign will be used. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] The campaign ID or name of the campaign to which voucher(s) will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :vouchers_count Number of vouchers that should be added. + # @option opts [CampaignsVouchersCreateInBulkRequestBody] :campaigns_vouchers_create_in_bulk_request_body Specify the voucher parameters that you would like to overwrite. + # @return [Array<(CampaignsVouchersCreateResponseBody, Integer, Hash)>] CampaignsVouchersCreateResponseBody data, response status code and response headers + private def add_vouchers_to_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.add_vouchers_to_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.add_vouchers_to_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}/vouchers'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'vouchers_count'] = opts[:'vouchers_count'] if !opts[:'vouchers_count'].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[:'campaigns_vouchers_create_in_bulk_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsVouchersCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.add_vouchers_to_campaign", + :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: CampaignsApi#add_vouchers_to_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Create Campaign + # Method to create a batch of vouchers aggregated in one campaign. You can choose a variety of voucher types and define a unique pattern for generating codes. 📘 Global uniqueness All campaign codes are unique across the whole project. Voucherify will not allow you to generate 2 campaigns with the same coupon code. 🚧 Code generation status This is an asynchronous action; you cant read or modify a newly created campaign until the code generation is completed. See the creation_status field in the campaign object description. + # @param [Hash] opts the optional parameters + # @option opts [CampaignsCreateRequestBody] :campaigns_create_request_body Specify the details of the campaign that you would like to create. + # @return [CampaignsCreateResponseBody] + def create_campaign(opts = {}) + data, _status_code, _headers = create_campaign_with_http_info(opts) + data + end + + # Create Campaign + # Method to create a batch of vouchers aggregated in one campaign. You can choose a variety of voucher types and define a unique pattern for generating codes. 📘 Global uniqueness All campaign codes are unique across the whole project. Voucherify will not allow you to generate 2 campaigns with the same coupon code. 🚧 Code generation status This is an asynchronous action; you cant read or modify a newly created campaign until the code generation is completed. See the creation_status field in the campaign object description. + # @param [Hash] opts the optional parameters + # @option opts [CampaignsCreateRequestBody] :campaigns_create_request_body Specify the details of the campaign that you would like to create. + # @return [Array<(CampaignsCreateResponseBody, Integer, Hash)>] CampaignsCreateResponseBody data, response status code and response headers + private def create_campaign_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign ...' + end + # resource path + local_var_path = '/v1/campaigns' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'campaigns_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.create_campaign", + :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: CampaignsApi#create_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Campaign + # Permanently deletes a campaign and all related vouchers. This action cannot be undone. Also, this method immediately removes any redemptions on the voucher. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with exactly the same name. + # @return [CampaignsDeleteResponseBody] + def delete_campaign(campaign_id, opts = {}) + data, _status_code, _headers = delete_campaign_with_http_info(campaign_id, opts) + data + end + + # Delete Campaign + # Permanently deletes a campaign and all related vouchers. This action cannot be undone. Also, this method immediately removes any redemptions on the voucher. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with exactly the same name. + # @return [Array<(CampaignsDeleteResponseBody, Integer, Hash)>] CampaignsDeleteResponseBody data, response status code and response headers + private def delete_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.delete_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.delete_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsDeleteResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.delete_campaign", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CampaignsApi#delete_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Disable Campaign + # There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - *enable* and *disable*. Sets campaign state to **inactive**. The vouchers in this campaign can no longer be redeemed. + # @param campaign_id [String] The campaign ID or name of the campaign being disabled. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @return [CampaignsDisableResponseBody] + def disable_campaign(campaign_id, opts = {}) + data, _status_code, _headers = disable_campaign_with_http_info(campaign_id, opts) + data + end + + # Disable Campaign + # There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - *enable* and *disable*. Sets campaign state to **inactive**. The vouchers in this campaign can no longer be redeemed. + # @param campaign_id [String] The campaign ID or name of the campaign being disabled. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @return [Array<(CampaignsDisableResponseBody, Integer, Hash)>] CampaignsDisableResponseBody data, response status code and response headers + private def disable_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.disable_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.disable_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}/disable'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsDisableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.disable_campaign", + :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: CampaignsApi#disable_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Enable Campaign + # There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - *enable* and *disable*. Sets campaign state to **active**. The vouchers in this campaign can be redeemed - only if the redemption occurs after the start date of the campaign and voucher and the voucher and campaign are not expired. + # @param campaign_id [String] The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @return [CampaignsEnableResponseBody] + def enable_campaign(campaign_id, opts = {}) + data, _status_code, _headers = enable_campaign_with_http_info(campaign_id, opts) + data + end + + # Enable Campaign + # There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - *enable* and *disable*. Sets campaign state to **active**. The vouchers in this campaign can be redeemed - only if the redemption occurs after the start date of the campaign and voucher and the voucher and campaign are not expired. + # @param campaign_id [String] The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @return [Array<(CampaignsEnableResponseBody, Integer, Hash)>] CampaignsEnableResponseBody data, response status code and response headers + private def enable_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.enable_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.enable_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}/enable'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsEnableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.enable_campaign", + :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: CampaignsApi#enable_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Campaign + # Retrieves the campaign with the given campaign ID or campaign name. + # @param campaign_id [String] You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @return [CampaignsGetResponseBody] + def get_campaign(campaign_id, opts = {}) + data, _status_code, _headers = get_campaign_with_http_info(campaign_id, opts) + data + end + + # Get Campaign + # Retrieves the campaign with the given campaign ID or campaign name. + # @param campaign_id [String] You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @return [Array<(CampaignsGetResponseBody, Integer, Hash)>] CampaignsGetResponseBody data, response status code and response headers + private def get_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.get_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.get_campaign", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CampaignsApi#get_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import Vouchers to Campaign + # Imports vouchers to an **existing** campaign. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] The ID of an existing campaign to which youre importing the codes. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [Array] :campaigns_import_voucher_item Discount type, expiration date and the remaining attributes will be taken from the Campaign settings. + # @return [CampaignsImportCreateResponseBody] + def import_vouchers_to_campaign(campaign_id, opts = {}) + data, _status_code, _headers = import_vouchers_to_campaign_with_http_info(campaign_id, opts) + data + end + + # Import Vouchers to Campaign + # Imports vouchers to an **existing** campaign. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] The ID of an existing campaign to which youre importing the codes. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [Array] :campaigns_import_voucher_item Discount type, expiration date and the remaining attributes will be taken from the Campaign settings. + # @return [Array<(CampaignsImportCreateResponseBody, Integer, Hash)>] CampaignsImportCreateResponseBody data, response status code and response headers + private def import_vouchers_to_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.import_vouchers_to_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.import_vouchers_to_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}/import'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'campaigns_import_voucher_item']) + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsImportCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.import_vouchers_to_campaign", + :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: CampaignsApi#import_vouchers_to_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import Vouchers to Campaign by CSV + # Imports vouchers to an **existing** campaign. The CSV file has to include headers in the first line. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [CampaignsImportCsvCreateResponseBody] + def import_vouchers_to_campaign_using_csv(campaign_id, file, opts = {}) + data, _status_code, _headers = import_vouchers_to_campaign_using_csv_with_http_info(campaign_id, file, opts) + data + end + + # Import Vouchers to Campaign by CSV + # Imports vouchers to an **existing** campaign. The CSV file has to include headers in the first line. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param campaign_id [String] The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [Array<(CampaignsImportCsvCreateResponseBody, Integer, Hash)>] CampaignsImportCsvCreateResponseBody data, response status code and response headers + private def import_vouchers_to_campaign_using_csv_with_http_info(campaign_id, file, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.import_vouchers_to_campaign_using_csv ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.import_vouchers_to_campaign_using_csv" + end + # verify the required parameter 'file' is set + if @api_client.config.client_side_validation && file.nil? + fail ArgumentError, "Missing the required parameter 'file' when calling CampaignsApi.import_vouchers_to_campaign_using_csv" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}/importCSV'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['file'] = file + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsImportCsvCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.import_vouchers_to_campaign_using_csv", + :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: CampaignsApi#import_vouchers_to_campaign_using_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Campaigns + # Retrieve a list of campaigns in a project. The campaigns are returned sorted by creation date, with the most recent campaigns appearing first. When you get a list of campaigns, you can optionally specify query parameters to customize the amount of campaigns returned per call using limit, which page of campaigns to return using page, sort the campaigns using the order query parameter and filter the results by the campaign_type. This method will return an error when trying to return a limit of more than 100 campaigns. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterCampaignType] :campaign_type This attribute allows filtering by campaign type. + # @option opts [ParameterExpandListCampaigns] :expand Include an expanded categories object in the response. (default to 'category') + # @option opts [ParameterOrderListCampaigns] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [CampaignsListResponseBody] + def list_campaigns(opts = {}) + data, _status_code, _headers = list_campaigns_with_http_info(opts) + data + end + + # List Campaigns + # Retrieve a list of campaigns in a project. The campaigns are returned sorted by creation date, with the most recent campaigns appearing first. When you get a list of campaigns, you can optionally specify query parameters to customize the amount of campaigns returned per call using limit, which page of campaigns to return using page, sort the campaigns using the order query parameter and filter the results by the campaign_type. This method will return an error when trying to return a limit of more than 100 campaigns. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterCampaignType] :campaign_type This attribute allows filtering by campaign type. + # @option opts [ParameterExpandListCampaigns] :expand Include an expanded categories object in the response. (default to 'category') + # @option opts [ParameterOrderListCampaigns] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [Array<(CampaignsListResponseBody, Integer, Hash)>] CampaignsListResponseBody data, response status code and response headers + private def list_campaigns_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.list_campaigns ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CampaignsApi.list_campaigns, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CampaignsApi.list_campaigns, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling CampaignsApi.list_campaigns, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/campaigns' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'campaign_type'] = opts[:'campaign_type'] if !opts[:'campaign_type'].nil? + query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.list_campaigns", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CampaignsApi#list_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Campaign + # Updates the specified campaign by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. Fields other than the ones listed in the request body wont be modified. Even if provided, they will be silently skipped. ## Vouchers will be affected This method will update vouchers aggregated in the campaign. It will affect all vouchers that are not published or redeemed yet. + # @param campaign_id [String] You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [CampaignsUpdateRequestBody] :campaigns_update_request_body Specify the campaign parameters to be updated. + # @return [CampaignsUpdateResponseBody] + def update_campaign(campaign_id, opts = {}) + data, _status_code, _headers = update_campaign_with_http_info(campaign_id, opts) + data + end + + # Update Campaign + # Updates the specified campaign by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. Fields other than the ones listed in the request body wont be modified. Even if provided, they will be silently skipped. ## Vouchers will be affected This method will update vouchers aggregated in the campaign. It will affect all vouchers that are not published or redeemed yet. + # @param campaign_id [String] You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value. + # @param [Hash] opts the optional parameters + # @option opts [CampaignsUpdateRequestBody] :campaigns_update_request_body Specify the campaign parameters to be updated. + # @return [Array<(CampaignsUpdateResponseBody, Integer, Hash)>] CampaignsUpdateResponseBody data, response status code and response headers + private def update_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.update_campaign" + end + # resource path + local_var_path = '/v1/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'campaigns_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CampaignsUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CampaignsApi.update_campaign", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CampaignsApi#update_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/categories_api.rb b/lib/VoucherifySdk/api/categories_api.rb new file mode 100644 index 00000000..36a0a9ce --- /dev/null +++ b/lib/VoucherifySdk/api/categories_api.rb @@ -0,0 +1,337 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class CategoriesApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Category + # Create category with a specific name and hierarchy. + # @param [Hash] opts the optional parameters + # @option opts [CategoriesCreateRequestBody] :categories_create_request_body Specify the details of the category that you would like to create. + # @return [CategoriesCreateResponseBody] + def create_category(opts = {}) + data, _status_code, _headers = create_category_with_http_info(opts) + data + end + + # Create Category + # Create category with a specific name and hierarchy. + # @param [Hash] opts the optional parameters + # @option opts [CategoriesCreateRequestBody] :categories_create_request_body Specify the details of the category that you would like to create. + # @return [Array<(CategoriesCreateResponseBody, Integer, Hash)>] CategoriesCreateResponseBody data, response status code and response headers + private def create_category_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CategoriesApi.create_category ...' + end + # resource path + local_var_path = '/v1/categories' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'categories_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CategoriesCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CategoriesApi.create_category", + :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: CategoriesApi#create_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Category + # Delete a category by the category ID. + # @param category_id [String] Unique category ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_category(category_id, opts = {}) + delete_category_with_http_info(category_id, opts) + nil + end + + # Delete Category + # Delete a category by the category ID. + # @param category_id [String] Unique category ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_category_with_http_info(category_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CategoriesApi.delete_category ...' + end + # verify the required parameter 'category_id' is set + if @api_client.config.client_side_validation && category_id.nil? + fail ArgumentError, "Missing the required parameter 'category_id' when calling CategoriesApi.delete_category" + end + # resource path + local_var_path = '/v1/categories/{categoryId}'.sub('{' + 'categoryId' + '}', CGI.escape(category_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CategoriesApi.delete_category", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CategoriesApi#delete_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Category + # Retrieve a category by the category ID. + # @param category_id [String] Unique category ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @return [CategoriesGetResponseBody] + def get_category(category_id, opts = {}) + data, _status_code, _headers = get_category_with_http_info(category_id, opts) + data + end + + # Get Category + # Retrieve a category by the category ID. + # @param category_id [String] Unique category ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @return [Array<(CategoriesGetResponseBody, Integer, Hash)>] CategoriesGetResponseBody data, response status code and response headers + private def get_category_with_http_info(category_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CategoriesApi.get_category ...' + end + # verify the required parameter 'category_id' is set + if @api_client.config.client_side_validation && category_id.nil? + fail ArgumentError, "Missing the required parameter 'category_id' when calling CategoriesApi.get_category" + end + # resource path + local_var_path = '/v1/categories/{categoryId}'.sub('{' + 'categoryId' + '}', CGI.escape(category_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CategoriesGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CategoriesApi.get_category", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CategoriesApi#get_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Categories + # List all categories. + # @param [Hash] opts the optional parameters + # @return [CategoriesListResponseBody] + def list_categories(opts = {}) + data, _status_code, _headers = list_categories_with_http_info(opts) + data + end + + # List Categories + # List all categories. + # @param [Hash] opts the optional parameters + # @return [Array<(CategoriesListResponseBody, Integer, Hash)>] CategoriesListResponseBody data, response status code and response headers + private def list_categories_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CategoriesApi.list_categories ...' + end + # resource path + local_var_path = '/v1/categories' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CategoriesListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CategoriesApi.list_categories", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CategoriesApi#list_categories\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Category + # Update category using the category ID. + # @param category_id [String] Unique category ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @option opts [CategoriesUpdateRequestBody] :categories_update_request_body Specify the details of the category that you would like to update. + # @return [CategoriesUpdateResponseBody] + def update_category(category_id, opts = {}) + data, _status_code, _headers = update_category_with_http_info(category_id, opts) + data + end + + # Update Category + # Update category using the category ID. + # @param category_id [String] Unique category ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @option opts [CategoriesUpdateRequestBody] :categories_update_request_body Specify the details of the category that you would like to update. + # @return [Array<(CategoriesUpdateResponseBody, Integer, Hash)>] CategoriesUpdateResponseBody data, response status code and response headers + private def update_category_with_http_info(category_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CategoriesApi.update_category ...' + end + # verify the required parameter 'category_id' is set + if @api_client.config.client_side_validation && category_id.nil? + fail ArgumentError, "Missing the required parameter 'category_id' when calling CategoriesApi.update_category" + end + # resource path + local_var_path = '/v1/categories/{categoryId}'.sub('{' + 'categoryId' + '}', CGI.escape(category_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'categories_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CategoriesUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CategoriesApi.update_category", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CategoriesApi#update_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/client_side_api.rb b/lib/VoucherifySdk/api/client_side_api.rb new file mode 100644 index 00000000..88e9a828 --- /dev/null +++ b/lib/VoucherifySdk/api/client_side_api.rb @@ -0,0 +1,367 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class ClientSideApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Check Eligibility (client-side) + # Generate a list of redeemables that are applicable in the context of the customer and order. The new qualifications method is an improved version of Campaign Qualifications, Voucher Qualifications, and Promotions Validation API requests. The new qualification method introduces the following improvements: - Qualification results are returned faster - No limit on the number of returned redeemables - Introduces new qualification scenarios, not available in the previous version 👍 Scenario Guide Read our dedicated guide to learn about some use cases this endpoint can cover here. # Paging The Voucherify Qualifications API request will return to you all of the redeemables available for the customer in batches of up to 50 redeemables. To get the next batch of redeemables, you need to use the starting_after cursor. To process of paging the redeemables works in the following manner: - You send the first API request for Qualifications without the starting_after parameter. - The response will contain a parameter named has_more. If the parameters value is set to true, then more redeemables are available. - Get the value of the created_at parameter of the last returned redeemable. The value of this parameter will be used as a cursor to retrieve the next page of redeemables. - Send another API request for Qualification with the starting_after parameter set to the value taken from the created_at parameter from the last returned redeemable. - Voucherify will return the next page of redeemables. - If the has_more parameter is set to true, apply steps 3-5 to get the next page of redeemables. + # @param [Hash] opts the optional parameters + # @option opts [ClientQualificationsCheckEligibilityRequestBody] :client_qualifications_check_eligibility_request_body Define order and customer context. + # @return [ClientQualificationsCheckEligibilityResponseBody] + def check_eligibility_client_side(opts = {}) + data, _status_code, _headers = check_eligibility_client_side_with_http_info(opts) + data + end + + # Check Eligibility (client-side) + # Generate a list of redeemables that are applicable in the context of the customer and order. The new qualifications method is an improved version of Campaign Qualifications, Voucher Qualifications, and Promotions Validation API requests. The new qualification method introduces the following improvements: - Qualification results are returned faster - No limit on the number of returned redeemables - Introduces new qualification scenarios, not available in the previous version 👍 Scenario Guide Read our dedicated guide to learn about some use cases this endpoint can cover here. # Paging The Voucherify Qualifications API request will return to you all of the redeemables available for the customer in batches of up to 50 redeemables. To get the next batch of redeemables, you need to use the starting_after cursor. To process of paging the redeemables works in the following manner: - You send the first API request for Qualifications without the starting_after parameter. - The response will contain a parameter named has_more. If the parameters value is set to true, then more redeemables are available. - Get the value of the created_at parameter of the last returned redeemable. The value of this parameter will be used as a cursor to retrieve the next page of redeemables. - Send another API request for Qualification with the starting_after parameter set to the value taken from the created_at parameter from the last returned redeemable. - Voucherify will return the next page of redeemables. - If the has_more parameter is set to true, apply steps 3-5 to get the next page of redeemables. + # @param [Hash] opts the optional parameters + # @option opts [ClientQualificationsCheckEligibilityRequestBody] :client_qualifications_check_eligibility_request_body Define order and customer context. + # @return [Array<(ClientQualificationsCheckEligibilityResponseBody, Integer, Hash)>] ClientQualificationsCheckEligibilityResponseBody data, response status code and response headers + private def check_eligibility_client_side_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ClientSideApi.check_eligibility_client_side ...' + end + # resource path + local_var_path = '/client/v1/qualifications' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'client_qualifications_check_eligibility_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ClientQualificationsCheckEligibilityResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-Client-Application-Id', 'X-Client-Token'] + + new_options = opts.merge( + :operation => :"ClientSideApi.check_eligibility_client_side", + :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: ClientSideApi#check_eligibility_client_side\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Redeem Stackable Discounts (client-side) + # This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. # How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: 📘 Rollbacks You cant roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your rollback request. + # @param origin [String] Indicates the origin (scheme, hostname, and port). + # @param [Hash] opts the optional parameters + # @option opts [ClientRedemptionsRedeemRequestBody] :client_redemptions_redeem_request_body + # @return [ClientRedemptionsRedeemResponseBody] + def redeem_stacked_discounts_client_side(origin, opts = {}) + data, _status_code, _headers = redeem_stacked_discounts_client_side_with_http_info(origin, opts) + data + end + + # Redeem Stackable Discounts (client-side) + # This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. # How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: 📘 Rollbacks You cant roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your rollback request. + # @param origin [String] Indicates the origin (scheme, hostname, and port). + # @param [Hash] opts the optional parameters + # @option opts [ClientRedemptionsRedeemRequestBody] :client_redemptions_redeem_request_body + # @return [Array<(ClientRedemptionsRedeemResponseBody, Integer, Hash)>] ClientRedemptionsRedeemResponseBody data, response status code and response headers + private def redeem_stacked_discounts_client_side_with_http_info(origin, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ClientSideApi.redeem_stacked_discounts_client_side ...' + end + # verify the required parameter 'origin' is set + if @api_client.config.client_side_validation && origin.nil? + fail ArgumentError, "Missing the required parameter 'origin' when calling ClientSideApi.redeem_stacked_discounts_client_side" + end + # resource path + local_var_path = '/client/v1/redemptions' + + # query parameters + query_params = opts[:query_params] || {} + + # 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 + header_params[:'origin'] = origin + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'client_redemptions_redeem_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ClientRedemptionsRedeemResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-Client-Application-Id', 'X-Client-Token'] + + new_options = opts.merge( + :operation => :"ClientSideApi.redeem_stacked_discounts_client_side", + :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: ClientSideApi#redeem_stacked_discounts_client_side\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Track Custom Event (client-side) + # To track a custom event, you create an event object. The event object must be linked to the customer who performs the action. If a customer doesnt exist in Voucherify, the customer will be created. + # @param origin [String] Indicates the origin (scheme, hostname, and port). + # @param [Hash] opts the optional parameters + # @option opts [ClientEventsCreateRequestBody] :client_events_create_request_body Specify the details of the custom event. + # @return [ClientEventsCreateResponseBody] + def track_custom_event_client_side(origin, opts = {}) + data, _status_code, _headers = track_custom_event_client_side_with_http_info(origin, opts) + data + end + + # Track Custom Event (client-side) + # To track a custom event, you create an event object. The event object must be linked to the customer who performs the action. If a customer doesnt exist in Voucherify, the customer will be created. + # @param origin [String] Indicates the origin (scheme, hostname, and port). + # @param [Hash] opts the optional parameters + # @option opts [ClientEventsCreateRequestBody] :client_events_create_request_body Specify the details of the custom event. + # @return [Array<(ClientEventsCreateResponseBody, Integer, Hash)>] ClientEventsCreateResponseBody data, response status code and response headers + private def track_custom_event_client_side_with_http_info(origin, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ClientSideApi.track_custom_event_client_side ...' + end + # verify the required parameter 'origin' is set + if @api_client.config.client_side_validation && origin.nil? + fail ArgumentError, "Missing the required parameter 'origin' when calling ClientSideApi.track_custom_event_client_side" + end + # resource path + local_var_path = '/client/v1/events' + + # query parameters + query_params = opts[:query_params] || {} + + # 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 + header_params[:'origin'] = origin + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'client_events_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ClientEventsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-Client-Application-Id', 'X-Client-Token'] + + new_options = opts.merge( + :operation => :"ClientSideApi.track_custom_event_client_side", + :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: ClientSideApi#track_custom_event_client_side\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Customer's consents (client-side) + # Update marketing permissions for the specified customer. + # @param customer_id [String] A Voucherify customer identifier or source_id + # @param [Hash] opts the optional parameters + # @option opts [Object] :body Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: + # @return [nil] + def update_customers_consents_client_side(customer_id, opts = {}) + update_customers_consents_client_side_with_http_info(customer_id, opts) + nil + end + + # Update Customer's consents (client-side) + # Update marketing permissions for the specified customer. + # @param customer_id [String] A Voucherify customer identifier or source_id + # @param [Hash] opts the optional parameters + # @option opts [Object] :body Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def update_customers_consents_client_side_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ClientSideApi.update_customers_consents_client_side ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling ClientSideApi.update_customers_consents_client_side" + end + # resource path + local_var_path = '/client/v1/customers/{customerId}/consents'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # 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[:'body']) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-Client-Application-Id', 'X-Client-Token'] + + new_options = opts.merge( + :operation => :"ClientSideApi.update_customers_consents_client_side", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ClientSideApi#update_customers_consents_client_side\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Validate Stackable Discounts (client-side) + # Verify redeemables provided in the request. This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. + # @param origin [String] Indicates the origin (scheme, hostname, and port). + # @param [Hash] opts the optional parameters + # @option opts [ClientValidationsValidateRequestBody] :client_validations_validate_request_body + # @return [ClientValidationsValidateResponseBody] + def validate_stacked_discounts_client_side(origin, opts = {}) + data, _status_code, _headers = validate_stacked_discounts_client_side_with_http_info(origin, opts) + data + end + + # Validate Stackable Discounts (client-side) + # Verify redeemables provided in the request. This method is accessible through public keys which you can use in client side requests coming from mobile and web browser applications. + # @param origin [String] Indicates the origin (scheme, hostname, and port). + # @param [Hash] opts the optional parameters + # @option opts [ClientValidationsValidateRequestBody] :client_validations_validate_request_body + # @return [Array<(ClientValidationsValidateResponseBody, Integer, Hash)>] ClientValidationsValidateResponseBody data, response status code and response headers + private def validate_stacked_discounts_client_side_with_http_info(origin, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ClientSideApi.validate_stacked_discounts_client_side ...' + end + # verify the required parameter 'origin' is set + if @api_client.config.client_side_validation && origin.nil? + fail ArgumentError, "Missing the required parameter 'origin' when calling ClientSideApi.validate_stacked_discounts_client_side" + end + # resource path + local_var_path = '/client/v1/validations' + + # query parameters + query_params = opts[:query_params] || {} + + # 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 + header_params[:'origin'] = origin + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'client_validations_validate_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ClientValidationsValidateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-Client-Application-Id', 'X-Client-Token'] + + new_options = opts.merge( + :operation => :"ClientSideApi.validate_stacked_discounts_client_side", + :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: ClientSideApi#validate_stacked_discounts_client_side\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/customers_api.rb b/lib/VoucherifySdk/api/customers_api.rb new file mode 100644 index 00000000..2a46f99e --- /dev/null +++ b/lib/VoucherifySdk/api/customers_api.rb @@ -0,0 +1,874 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class CustomersApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Customer + # Creates a customer object. 📘 Upsert Mode If you pass an id or a source_id that already exists in the customer database, Voucherify will return a related customer object with updated fields. + # @param [Hash] opts the optional parameters + # @option opts [CustomersCreateRequestBody] :customers_create_request_body Create a customer with specified parameters. + # @return [CustomersCreateResponseBody] + def create_customer(opts = {}) + data, _status_code, _headers = create_customer_with_http_info(opts) + data + end + + # Create Customer + # Creates a customer object. 📘 Upsert Mode If you pass an id or a source_id that already exists in the customer database, Voucherify will return a related customer object with updated fields. + # @param [Hash] opts the optional parameters + # @option opts [CustomersCreateRequestBody] :customers_create_request_body Create a customer with specified parameters. + # @return [Array<(CustomersCreateResponseBody, Integer, Hash)>] CustomersCreateResponseBody data, response status code and response headers + private def create_customer_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.create_customer ...' + end + # resource path + local_var_path = '/v1/customers' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'customers_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CustomersCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.create_customer", + :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: CustomersApi#create_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Customer Permanently + # The organization user can remove consumer data permanently from the Voucherify system by using this API method. It deletes all customer data and connected resources. It makes the customer profile forgotten by Voucherify. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @return [CustomersPermanentDeletionCreateResponseBody] + def customer_permanently_deletion(customer_id, opts = {}) + data, _status_code, _headers = customer_permanently_deletion_with_http_info(customer_id, opts) + data + end + + # Delete Customer Permanently + # The organization user can remove consumer data permanently from the Voucherify system by using this API method. It deletes all customer data and connected resources. It makes the customer profile forgotten by Voucherify. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @return [Array<(CustomersPermanentDeletionCreateResponseBody, Integer, Hash)>] CustomersPermanentDeletionCreateResponseBody data, response status code and response headers + private def customer_permanently_deletion_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.customer_permanently_deletion ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.customer_permanently_deletion" + end + # resource path + local_var_path = '/v1/customers/{customerId}/permanent-deletion'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomersPermanentDeletionCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.customer_permanently_deletion", + :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: CustomersApi#customer_permanently_deletion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Customer + # This method deletes a customer. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_customer(customer_id, opts = {}) + delete_customer_with_http_info(customer_id, opts) + nil + end + + # Delete Customer + # This method deletes a customer. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_customer_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.delete_customer ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.delete_customer" + end + # resource path + local_var_path = '/v1/customers/{customerId}'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.delete_customer", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CustomersApi#delete_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Customer + # Retrieve customer details. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @return [CustomersGetResponseBody] + def get_customer(customer_id, opts = {}) + data, _status_code, _headers = get_customer_with_http_info(customer_id, opts) + data + end + + # Get Customer + # Retrieve customer details. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @return [Array<(CustomersGetResponseBody, Integer, Hash)>] CustomersGetResponseBody data, response status code and response headers + private def get_customer_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.get_customer ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.get_customer" + end + # resource path + local_var_path = '/v1/customers/{customerId}'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomersGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.get_customer", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CustomersApi#get_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import and Update Customers using CSV + # This API method lets you import or update customer data. To get a proper and valid response, please send a CSV file with data separated by commas. # Request Example # CSV File Format The CSV file has to include headers in the first line. All properties which cannot be mapped to standard customer fields will be added to the metadata object. 📘 Standard customer fields mapping **No spaces allowed in field names** Id, Name, Email, Phone, Birthdate, Source_id, Address_line_1, Address_line_2, Address_Postal_Code, Address_City, Address_State, Address_Country, Description, Metadata_name_1, Metadata_name_2 # Update Customers using CSV If you would like to update customers data, you can do it using the CSV file with new data. However, remember to include a source_id in your CSV file to manage the update successfully. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [CustomersImportCsvCreateResponseBody] + def import_customers_using_csv(file, opts = {}) + data, _status_code, _headers = import_customers_using_csv_with_http_info(file, opts) + data + end + + # Import and Update Customers using CSV + # This API method lets you import or update customer data. To get a proper and valid response, please send a CSV file with data separated by commas. # Request Example # CSV File Format The CSV file has to include headers in the first line. All properties which cannot be mapped to standard customer fields will be added to the metadata object. 📘 Standard customer fields mapping **No spaces allowed in field names** Id, Name, Email, Phone, Birthdate, Source_id, Address_line_1, Address_line_2, Address_Postal_Code, Address_City, Address_State, Address_Country, Description, Metadata_name_1, Metadata_name_2 # Update Customers using CSV If you would like to update customers data, you can do it using the CSV file with new data. However, remember to include a source_id in your CSV file to manage the update successfully. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [Array<(CustomersImportCsvCreateResponseBody, Integer, Hash)>] CustomersImportCsvCreateResponseBody data, response status code and response headers + private def import_customers_using_csv_with_http_info(file, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.import_customers_using_csv ...' + end + # verify the required parameter 'file' is set + if @api_client.config.client_side_validation && file.nil? + fail ArgumentError, "Missing the required parameter 'file' when calling CustomersApi.import_customers_using_csv" + end + # resource path + local_var_path = '/v1/customers/importCSV' + + # query parameters + query_params = opts[:query_params] || {} + + # 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(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['file'] = file + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomersImportCsvCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.import_customers_using_csv", + :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: CustomersApi#import_customers_using_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Customer Activities + # Retrieve customer activities. + # @param customer_id [String] A Voucherify customers id or source ID of the customer who performed the activities. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :starting_after A cursor for use in pagination. starting_after is a date-time value that defines your place in the list based on created_at property from the activity object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. + # @option opts [String] :starting_after_id By applying this filter value, you will get events starting after an event with the given ID. + # @option opts [ParameterCampaignType] :campaign_type Through this parameter you can control a type of campaign by which Voucherify will filter related customers activity. API will return only records related to that given type. Allowed values: DISCOUNT_COUPONS, REFERRAL_PROGRAM, GIFT_VOUCHERS, PROMOTION, LOYALTY_PROGRAM + # @option opts [String] :campaign_id By applying this parameter you request only events related to specific campaign identified by its ID. + # @option opts [String] :product_id By applying this parameter you request only events related to specific product identified by its ID. + # @option opts [Time] :start_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [CustomersActivitiesListResponseBody] + def list_customer_activities(customer_id, opts = {}) + data, _status_code, _headers = list_customer_activities_with_http_info(customer_id, opts) + data + end + + # List Customer Activities + # Retrieve customer activities. + # @param customer_id [String] A Voucherify customers id or source ID of the customer who performed the activities. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :starting_after A cursor for use in pagination. starting_after is a date-time value that defines your place in the list based on created_at property from the activity object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. + # @option opts [String] :starting_after_id By applying this filter value, you will get events starting after an event with the given ID. + # @option opts [ParameterCampaignType] :campaign_type Through this parameter you can control a type of campaign by which Voucherify will filter related customers activity. API will return only records related to that given type. Allowed values: DISCOUNT_COUPONS, REFERRAL_PROGRAM, GIFT_VOUCHERS, PROMOTION, LOYALTY_PROGRAM + # @option opts [String] :campaign_id By applying this parameter you request only events related to specific campaign identified by its ID. + # @option opts [String] :product_id By applying this parameter you request only events related to specific product identified by its ID. + # @option opts [Time] :start_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [Array<(CustomersActivitiesListResponseBody, Integer, Hash)>] CustomersActivitiesListResponseBody data, response status code and response headers + private def list_customer_activities_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.list_customer_activities ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.list_customer_activities" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CustomersApi.list_customer_activities, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CustomersApi.list_customer_activities, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/v1/customers/{customerId}/activities'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'starting_after'] = opts[:'starting_after'] if !opts[:'starting_after'].nil? + query_params[:'starting_after_id'] = opts[:'starting_after_id'] if !opts[:'starting_after_id'].nil? + query_params[:'campaign_type'] = opts[:'campaign_type'] if !opts[:'campaign_type'].nil? + query_params[:'campaign_id'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil? + query_params[:'product_id'] = opts[:'product_id'] if !opts[:'product_id'].nil? + query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil? + query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomersActivitiesListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.list_customer_activities", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CustomersApi#list_customer_activities\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Customer's Segments + # Returns the list of segments IDs to which the customer belongs to. If you pass a customerId which is not stored and recognized by Voucherify as an existing customer in the system, the response will generate a list of segments that the customer would potentialy qualify for if they were to become a customer tracked in the system. + # @param customer_id [String] Unique identifier of a customer represented by an internal customer ID or customer source ID. + # @param [Hash] opts the optional parameters + # @return [CustomersSegmentsListResponseBody] + def list_customer_segments(customer_id, opts = {}) + data, _status_code, _headers = list_customer_segments_with_http_info(customer_id, opts) + data + end + + # List Customer's Segments + # Returns the list of segments IDs to which the customer belongs to. If you pass a customerId which is not stored and recognized by Voucherify as an existing customer in the system, the response will generate a list of segments that the customer would potentialy qualify for if they were to become a customer tracked in the system. + # @param customer_id [String] Unique identifier of a customer represented by an internal customer ID or customer source ID. + # @param [Hash] opts the optional parameters + # @return [Array<(CustomersSegmentsListResponseBody, Integer, Hash)>] CustomersSegmentsListResponseBody data, response status code and response headers + private def list_customer_segments_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.list_customer_segments ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.list_customer_segments" + end + # resource path + local_var_path = '/v1/customers/{customerId}/segments'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomersSegmentsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.list_customer_segments", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CustomersApi#list_customer_segments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Customers + # Returns a list of customers. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [String] :email Limit the customers to the ones that have this specific email address. + # @option opts [String] :city Limit the customers to the ones that are located in the specified city. + # @option opts [String] :name Filter customers by the name property. + # @option opts [String] :segment_id Filter customers by the segment id. + # @option opts [Time] :created_at_before Filter customers by date customer was created. + # @option opts [Time] :created_at_after Filter customers by date customer was created. + # @option opts [Time] :updated_at_before Filter customers by date customer was updated last time. + # @option opts [Time] :updated_at_after Filter customers by date customer was updated last time. + # @option opts [ParameterOrderListCustomers] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :starting_after A cursor for use in pagination. This is a date-time value that defines your place in the list based on created_at property from the customer object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. + # @return [CustomersListResponseBody] + def list_customers(opts = {}) + data, _status_code, _headers = list_customers_with_http_info(opts) + data + end + + # List Customers + # Returns a list of customers. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [String] :email Limit the customers to the ones that have this specific email address. + # @option opts [String] :city Limit the customers to the ones that are located in the specified city. + # @option opts [String] :name Filter customers by the name property. + # @option opts [String] :segment_id Filter customers by the segment id. + # @option opts [Time] :created_at_before Filter customers by date customer was created. + # @option opts [Time] :created_at_after Filter customers by date customer was created. + # @option opts [Time] :updated_at_before Filter customers by date customer was updated last time. + # @option opts [Time] :updated_at_after Filter customers by date customer was updated last time. + # @option opts [ParameterOrderListCustomers] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :starting_after A cursor for use in pagination. This is a date-time value that defines your place in the list based on created_at property from the customer object. For instance, if you make a list request and receive 100 objects, ending with an object created at 2020-05-24T13:43:09.024Z, your subsequent call can include starting_after 2020-05-24T13:43:09.024Z in order to fetch the next page of the list. + # @return [Array<(CustomersListResponseBody, Integer, Hash)>] CustomersListResponseBody data, response status code and response headers + private def list_customers_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.list_customers ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CustomersApi.list_customers, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CustomersApi.list_customers, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling CustomersApi.list_customers, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/customers' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'email'] = opts[:'email'] if !opts[:'email'].nil? + query_params[:'city'] = opts[:'city'] if !opts[:'city'].nil? + query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil? + query_params[:'segment_id'] = opts[:'segment_id'] if !opts[:'segment_id'].nil? + query_params[:'created_at[before]'] = opts[:'created_at_before'] if !opts[:'created_at_before'].nil? + query_params[:'created_at[after]'] = opts[:'created_at_after'] if !opts[:'created_at_after'].nil? + query_params[:'updated_at[before]'] = opts[:'updated_at_before'] if !opts[:'updated_at_before'].nil? + query_params[:'updated_at[after]'] = opts[:'updated_at_after'] if !opts[:'updated_at_after'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'starting_after'] = opts[:'starting_after'] if !opts[:'starting_after'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomersListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.list_customers", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CustomersApi#list_customers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Customer + # Updates the specified customer by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @option opts [CustomersUpdateRequestBody] :customers_update_request_body Specify the parameters to be updated. + # @return [CustomersUpdateResponseBody] + def update_customer(customer_id, opts = {}) + data, _status_code, _headers = update_customer_with_http_info(customer_id, opts) + data + end + + # Update Customer + # Updates the specified customer by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. + # @param customer_id [String] A Voucherify customers id or source_id. + # @param [Hash] opts the optional parameters + # @option opts [CustomersUpdateRequestBody] :customers_update_request_body Specify the parameters to be updated. + # @return [Array<(CustomersUpdateResponseBody, Integer, Hash)>] CustomersUpdateResponseBody data, response status code and response headers + private def update_customer_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.update_customer ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.update_customer" + end + # resource path + local_var_path = '/v1/customers/{customerId}'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'customers_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CustomersUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.update_customer", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CustomersApi#update_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Customer's consents + # Update marketing permissions for the specified customer. + # @param customer_id [String] A Voucherify unique customer identifier or source ID. + # @param [Hash] opts the optional parameters + # @option opts [Object] :body Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: + # @return [nil] + def update_customers_consents(customer_id, opts = {}) + update_customers_consents_with_http_info(customer_id, opts) + nil + end + + # Update Customer's consents + # Update marketing permissions for the specified customer. + # @param customer_id [String] A Voucherify unique customer identifier or source ID. + # @param [Hash] opts the optional parameters + # @option opts [Object] :body Key-value pairs where the key is the consent identifier and value is a boolean that identifies if a customer has given the consent or not. To deny all consents use unsubscribed as a consent identifier and true as its value. ## Examples Opt-out from all communication: + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def update_customers_consents_with_http_info(customer_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.update_customers_consents ...' + end + # verify the required parameter 'customer_id' is set + if @api_client.config.client_side_validation && customer_id.nil? + fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.update_customers_consents" + end + # resource path + local_var_path = '/v1/customers/{customerId}/consents'.sub('{' + 'customerId' + '}', CGI.escape(customer_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # 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[:'body']) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.update_customers_consents", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CustomersApi#update_customers_consents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Customers in bulk + # Update several customers in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested customer object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [Array] :customers_update_in_bulk_request_body Specify the customer fields that you would like to update in each customer object. + # @return [CustomersUpdateInBulkResponseBody] + def update_customers_in_bulk(opts = {}) + data, _status_code, _headers = update_customers_in_bulk_with_http_info(opts) + data + end + + # Update Customers in bulk + # Update several customers in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested customer object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [Array] :customers_update_in_bulk_request_body Specify the customer fields that you would like to update in each customer object. + # @return [Array<(CustomersUpdateInBulkResponseBody, Integer, Hash)>] CustomersUpdateInBulkResponseBody data, response status code and response headers + private def update_customers_in_bulk_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.update_customers_in_bulk ...' + end + # resource path + local_var_path = '/v1/customers/bulk/async' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'customers_update_in_bulk_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CustomersUpdateInBulkResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.update_customers_in_bulk", + :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: CustomersApi#update_customers_in_bulk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Customers' Metadata in bulk + # Update several customers metadata properties in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested customer object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [CustomersMetadataUpdateInBulkRequestBody] :customers_metadata_update_in_bulk_request_body List the source_ids of the customers you would like to update along with the metadata key value pairs. + # @return [CustomersMetadataUpdateInBulkResponseBody] + def update_customers_metadata_in_bulk(opts = {}) + data, _status_code, _headers = update_customers_metadata_in_bulk_with_http_info(opts) + data + end + + # Update Customers' Metadata in bulk + # Update several customers metadata properties in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested customer object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [CustomersMetadataUpdateInBulkRequestBody] :customers_metadata_update_in_bulk_request_body List the source_ids of the customers you would like to update along with the metadata key value pairs. + # @return [Array<(CustomersMetadataUpdateInBulkResponseBody, Integer, Hash)>] CustomersMetadataUpdateInBulkResponseBody data, response status code and response headers + private def update_customers_metadata_in_bulk_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CustomersApi.update_customers_metadata_in_bulk ...' + end + # resource path + local_var_path = '/v1/customers/metadata/async' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'customers_metadata_update_in_bulk_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'CustomersMetadataUpdateInBulkResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"CustomersApi.update_customers_metadata_in_bulk", + :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: CustomersApi#update_customers_metadata_in_bulk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/events_api.rb b/lib/VoucherifySdk/api/events_api.rb new file mode 100644 index 00000000..210271fd --- /dev/null +++ b/lib/VoucherifySdk/api/events_api.rb @@ -0,0 +1,86 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class EventsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Track Custom Event + # To track a custom event, you create an event object. The event object must be linked to the customer who performs the action. If a customer doesnt exist in Voucherify, the customer will be created. + # @param [Hash] opts the optional parameters + # @option opts [EventsCreateRequestBody] :events_create_request_body Specify the details of the custom event. + # @return [EventsCreateResponseBody] + def track_custom_event(opts = {}) + data, _status_code, _headers = track_custom_event_with_http_info(opts) + data + end + + # Track Custom Event + # To track a custom event, you create an event object. The event object must be linked to the customer who performs the action. If a customer doesnt exist in Voucherify, the customer will be created. + # @param [Hash] opts the optional parameters + # @option opts [EventsCreateRequestBody] :events_create_request_body Specify the details of the custom event. + # @return [Array<(EventsCreateResponseBody, Integer, Hash)>] EventsCreateResponseBody data, response status code and response headers + private def track_custom_event_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: EventsApi.track_custom_event ...' + end + # resource path + local_var_path = '/v1/events' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'events_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'EventsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"EventsApi.track_custom_event", + :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: EventsApi#track_custom_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/exports_api.rb b/lib/VoucherifySdk/api/exports_api.rb new file mode 100644 index 00000000..e1b296d8 --- /dev/null +++ b/lib/VoucherifySdk/api/exports_api.rb @@ -0,0 +1,354 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class ExportsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Export + # Create export object. The export can be any of the following types: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # Defaults If you only specify the object type in the request body without specifying the fields, the API will return the following fields per export object: # Fetching particular data sets Using the parameters body parameter, you can narrow down which fields to export and how to filter the results. The fields are an array of strings containing the data that you would like to export. These fields define the headers in the CSV file. The array can be a combintation of any of the following available fields: # Orders # Vouchers # Publications # Redemptions # Customers # Points Expirations # Gift Card Transactions # Loyalty Card Transactions + # @param [Hash] opts the optional parameters + # @option opts [ExportsCreateRequestBody] :exports_create_request_body Specify the details of the export that you would like to create. + # @return [ExportsCreateResponseBody] + def create_export(opts = {}) + data, _status_code, _headers = create_export_with_http_info(opts) + data + end + + # Create Export + # Create export object. The export can be any of the following types: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # Defaults If you only specify the object type in the request body without specifying the fields, the API will return the following fields per export object: # Fetching particular data sets Using the parameters body parameter, you can narrow down which fields to export and how to filter the results. The fields are an array of strings containing the data that you would like to export. These fields define the headers in the CSV file. The array can be a combintation of any of the following available fields: # Orders # Vouchers # Publications # Redemptions # Customers # Points Expirations # Gift Card Transactions # Loyalty Card Transactions + # @param [Hash] opts the optional parameters + # @option opts [ExportsCreateRequestBody] :exports_create_request_body Specify the details of the export that you would like to create. + # @return [Array<(ExportsCreateResponseBody, Integer, Hash)>] ExportsCreateResponseBody data, response status code and response headers + private def create_export_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExportsApi.create_export ...' + end + # resource path + local_var_path = '/v1/exports' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'exports_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ExportsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ExportsApi.create_export", + :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: ExportsApi#create_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Export + # This method deletes a previously created export object. + # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_export(export_id, opts = {}) + delete_export_with_http_info(export_id, opts) + nil + end + + # Delete Export + # This method deletes a previously created export object. + # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_export_with_http_info(export_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExportsApi.delete_export ...' + end + # verify the required parameter 'export_id' is set + if @api_client.config.client_side_validation && export_id.nil? + fail ArgumentError, "Missing the required parameter 'export_id' when calling ExportsApi.delete_export" + end + # resource path + local_var_path = '/v1/exports/{exportId}'.sub('{' + 'exportId' + '}', CGI.escape(export_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ExportsApi.delete_export", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ExportsApi#delete_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Download Export + # Download the contents of the exported CSV file. 📘 Important notes **Base URL:** - https://download.voucherify.io (Europe) - https://us1.download.voucherify.io (US) - https://as1.download.voucherify.io (Asia) **Token:** Can be found within the result parameter of the Get Export method response. + # @param export_id [String] Unique export object ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :token Token that was issued to the export, to get this token, get the export first + # @return [String] + def download_export(export_id, opts = {}) + data, _status_code, _headers = download_export_with_http_info(export_id, opts) + data + end + + # Download Export + # Download the contents of the exported CSV file. 📘 Important notes **Base URL:** - https://download.voucherify.io (Europe) - https://us1.download.voucherify.io (US) - https://as1.download.voucherify.io (Asia) **Token:** Can be found within the result parameter of the Get Export method response. + # @param export_id [String] Unique export object ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :token Token that was issued to the export, to get this token, get the export first + # @return [Array<(String, Integer, Hash)>] String data, response status code and response headers + private def download_export_with_http_info(export_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExportsApi.download_export ...' + end + # verify the required parameter 'export_id' is set + if @api_client.config.client_side_validation && export_id.nil? + fail ArgumentError, "Missing the required parameter 'export_id' when calling ExportsApi.download_export" + end + # resource path + local_var_path = '/v1/exports/{export_Id}'.sub('{' + 'export_Id' + '}', CGI.escape(export_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'token'] = opts[:'token'] if !opts[:'token'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['text/plain']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'String' + + # auth_names + auth_names = opts[:debug_auth_names] || [] + + new_options = opts.merge( + :operation => :"ExportsApi.download_export", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ExportsApi#download_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Export + # Retrieves the URL of the downloadable file, which was generated via the Create Export method. + # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. + # @param [Hash] opts the optional parameters + # @return [ExportsGetResponseBody] + def get_export(export_id, opts = {}) + data, _status_code, _headers = get_export_with_http_info(export_id, opts) + data + end + + # Get Export + # Retrieves the URL of the downloadable file, which was generated via the Create Export method. + # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. + # @param [Hash] opts the optional parameters + # @return [Array<(ExportsGetResponseBody, Integer, Hash)>] ExportsGetResponseBody data, response status code and response headers + private def get_export_with_http_info(export_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExportsApi.get_export ...' + end + # verify the required parameter 'export_id' is set + if @api_client.config.client_side_validation && export_id.nil? + fail ArgumentError, "Missing the required parameter 'export_id' when calling ExportsApi.get_export" + end + # resource path + local_var_path = '/v1/exports/{exportId}'.sub('{' + 'exportId' + '}', CGI.escape(export_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ExportsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ExportsApi.get_export", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ExportsApi#get_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Exports + # List all exports. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListExports] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [ExportsListResponseBody] + def list_exports(opts = {}) + data, _status_code, _headers = list_exports_with_http_info(opts) + data + end + + # List Exports + # List all exports. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListExports] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [Array<(ExportsListResponseBody, Integer, Hash)>] ExportsListResponseBody data, response status code and response headers + private def list_exports_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ExportsApi.list_exports ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ExportsApi.list_exports, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ExportsApi.list_exports, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ExportsApi.list_exports, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/exports' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ExportsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ExportsApi.list_exports", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ExportsApi#list_exports\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/loyalties_api.rb b/lib/VoucherifySdk/api/loyalties_api.rb new file mode 100644 index 00000000..d3787b95 --- /dev/null +++ b/lib/VoucherifySdk/api/loyalties_api.rb @@ -0,0 +1,1906 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class LoyaltiesApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create loyalty tiers + # Creates loyalty tiers for desired campaign. + # @param campaign_id [String] Unique loyalty campaign ID or name. + # @param [Hash] opts the optional parameters + # @option opts [Array] :loyalties_tiers_create_in_bulk_request_body_item Provide tier definitions you want to add to existing loyalty campaign. + # @return [Array] + def create_in_bulk_loyalty_tiers(campaign_id, opts = {}) + data, _status_code, _headers = create_in_bulk_loyalty_tiers_with_http_info(campaign_id, opts) + data + end + + # Create loyalty tiers + # Creates loyalty tiers for desired campaign. + # @param campaign_id [String] Unique loyalty campaign ID or name. + # @param [Hash] opts the optional parameters + # @option opts [Array] :loyalties_tiers_create_in_bulk_request_body_item Provide tier definitions you want to add to existing loyalty campaign. + # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + private def create_in_bulk_loyalty_tiers_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.create_in_bulk_loyalty_tiers ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.create_in_bulk_loyalty_tiers" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/tiers'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_tiers_create_in_bulk_request_body_item']) + + # return_type + return_type = opts[:debug_return_type] || 'Array' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.create_in_bulk_loyalty_tiers", + :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: LoyaltiesApi#create_in_bulk_loyalty_tiers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Earning Rule + # This method deletes an earning rule for a specific loyalty campaign. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param earning_rule_id [String] A unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_earning_rule(campaign_id, earning_rule_id, opts = {}) + delete_earning_rule_with_http_info(campaign_id, earning_rule_id, opts) + nil + end + + # Delete Earning Rule + # This method deletes an earning rule for a specific loyalty campaign. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param earning_rule_id [String] A unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_earning_rule_with_http_info(campaign_id, earning_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.delete_earning_rule ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.delete_earning_rule" + end + # verify the required parameter 'earning_rule_id' is set + if @api_client.config.client_side_validation && earning_rule_id.nil? + fail ArgumentError, "Missing the required parameter 'earning_rule_id' when calling LoyaltiesApi.delete_earning_rule" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'earningRuleId' + '}', CGI.escape(earning_rule_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.delete_earning_rule", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#delete_earning_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Loyalty Campaign + # This method permanently deletes a loyalty campaign and all related loyalty cards. This action cannot be undone. Also, it immediately removes any redemptions on loyalty cards. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with the same name. + # @return [LoyaltiesDeleteResponseBody] + def delete_loyalty_program(campaign_id, opts = {}) + data, _status_code, _headers = delete_loyalty_program_with_http_info(campaign_id, opts) + data + end + + # Delete Loyalty Campaign + # This method permanently deletes a loyalty campaign and all related loyalty cards. This action cannot be undone. Also, it immediately removes any redemptions on loyalty cards. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the campaign and related vouchers will be removed permanently. Going forward, the user will be able to create the next campaign with the same name. + # @return [Array<(LoyaltiesDeleteResponseBody, Integer, Hash)>] LoyaltiesDeleteResponseBody data, response status code and response headers + private def delete_loyalty_program_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.delete_loyalty_program ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.delete_loyalty_program" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesDeleteResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.delete_loyalty_program", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#delete_loyalty_program\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Reward Assignment + # This method deletes a reward assignment for a particular loyalty campaign. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_reward_assignment1(campaign_id, assignment_id, opts = {}) + delete_reward_assignment1_with_http_info(campaign_id, assignment_id, opts) + nil + end + + # Delete Reward Assignment + # This method deletes a reward assignment for a particular loyalty campaign. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_reward_assignment1_with_http_info(campaign_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.delete_reward_assignment1 ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.delete_reward_assignment1" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling LoyaltiesApi.delete_reward_assignment1" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/rewards/{assignmentId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.delete_reward_assignment1", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#delete_reward_assignment1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Disable Earning Rule + # Disable an earning rule. + # @param campaign_id [String] Unique campaign ID or name. + # @param earning_rule_id [String] Unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesEarningRulesDisableResponseBody] + def disable_earning_rule(campaign_id, earning_rule_id, opts = {}) + data, _status_code, _headers = disable_earning_rule_with_http_info(campaign_id, earning_rule_id, opts) + data + end + + # Disable Earning Rule + # Disable an earning rule. + # @param campaign_id [String] Unique campaign ID or name. + # @param earning_rule_id [String] Unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesEarningRulesDisableResponseBody, Integer, Hash)>] LoyaltiesEarningRulesDisableResponseBody data, response status code and response headers + private def disable_earning_rule_with_http_info(campaign_id, earning_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.disable_earning_rule ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.disable_earning_rule" + end + # verify the required parameter 'earning_rule_id' is set + if @api_client.config.client_side_validation && earning_rule_id.nil? + fail ArgumentError, "Missing the required parameter 'earning_rule_id' when calling LoyaltiesApi.disable_earning_rule" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/disable'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'earningRuleId' + '}', CGI.escape(earning_rule_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesEarningRulesDisableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.disable_earning_rule", + :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: LoyaltiesApi#disable_earning_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Enable Earning Rule + # Enable an earning rule. + # @param campaign_id [String] Unique campaign ID or name. + # @param earning_rule_id [String] Unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesEarningRulesEnableResponseBody] + def enable_earning_rule(campaign_id, earning_rule_id, opts = {}) + data, _status_code, _headers = enable_earning_rule_with_http_info(campaign_id, earning_rule_id, opts) + data + end + + # Enable Earning Rule + # Enable an earning rule. + # @param campaign_id [String] Unique campaign ID or name. + # @param earning_rule_id [String] Unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesEarningRulesEnableResponseBody, Integer, Hash)>] LoyaltiesEarningRulesEnableResponseBody data, response status code and response headers + private def enable_earning_rule_with_http_info(campaign_id, earning_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.enable_earning_rule ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.enable_earning_rule" + end + # verify the required parameter 'earning_rule_id' is set + if @api_client.config.client_side_validation && earning_rule_id.nil? + fail ArgumentError, "Missing the required parameter 'earning_rule_id' when calling LoyaltiesApi.enable_earning_rule" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}/enable'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'earningRuleId' + '}', CGI.escape(earning_rule_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesEarningRulesEnableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.enable_earning_rule", + :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: LoyaltiesApi#enable_earning_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Export Loyalty Card Transactions + # Export transactions that are associated with point movements on a loyalty card. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to export transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersTransactionsExportCreateRequestBody] :loyalties_members_transactions_export_create_request_body Specify the parameters and filters for the transaction export. + # @return [LoyaltiesMembersTransactionsExportCreateResponseBody] + def export_loyalty_card_transactions(member_id, opts = {}) + data, _status_code, _headers = export_loyalty_card_transactions_with_http_info(member_id, opts) + data + end + + # Export Loyalty Card Transactions + # Export transactions that are associated with point movements on a loyalty card. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to export transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersTransactionsExportCreateRequestBody] :loyalties_members_transactions_export_create_request_body Specify the parameters and filters for the transaction export. + # @return [Array<(LoyaltiesMembersTransactionsExportCreateResponseBody, Integer, Hash)>] LoyaltiesMembersTransactionsExportCreateResponseBody data, response status code and response headers + private def export_loyalty_card_transactions_with_http_info(member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.export_loyalty_card_transactions ...' + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.export_loyalty_card_transactions" + end + # resource path + local_var_path = '/v1/loyalties/members/{memberId}/transactions/export'.sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_members_transactions_export_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersTransactionsExportCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.export_loyalty_card_transactions", + :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: LoyaltiesApi#export_loyalty_card_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Export Loyalty Card Transactions + # Export transactions that are associated with point movements on a loyalty card. + # @param campaign_id [String] A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to export. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to export transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersTransactionsExportCreateRequestBody] :loyalties_members_transactions_export_create_request_body Specify the parameters and filters for the transaction export. + # @return [LoyaltiesMembersTransactionsExportCreateResponseBody] + def export_loyalty_card_transactions1(campaign_id, member_id, opts = {}) + data, _status_code, _headers = export_loyalty_card_transactions1_with_http_info(campaign_id, member_id, opts) + data + end + + # Export Loyalty Card Transactions + # Export transactions that are associated with point movements on a loyalty card. + # @param campaign_id [String] A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to export. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to export transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersTransactionsExportCreateRequestBody] :loyalties_members_transactions_export_create_request_body Specify the parameters and filters for the transaction export. + # @return [Array<(LoyaltiesMembersTransactionsExportCreateResponseBody, Integer, Hash)>] LoyaltiesMembersTransactionsExportCreateResponseBody data, response status code and response headers + private def export_loyalty_card_transactions1_with_http_info(campaign_id, member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.export_loyalty_card_transactions1 ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.export_loyalty_card_transactions1" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.export_loyalty_card_transactions1" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/members/{memberId}/transactions/export'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_members_transactions_export_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersTransactionsExportCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.export_loyalty_card_transactions1", + :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: LoyaltiesApi#export_loyalty_card_transactions1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Earning Rule + # Retrieves an earning rule assigned to a campaign. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param earning_rule_id [String] A unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesEarningRulesGetResponseBody] + def get_earning_rule(campaign_id, earning_rule_id, opts = {}) + data, _status_code, _headers = get_earning_rule_with_http_info(campaign_id, earning_rule_id, opts) + data + end + + # Get Earning Rule + # Retrieves an earning rule assigned to a campaign. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param earning_rule_id [String] A unique earning rule ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesEarningRulesGetResponseBody, Integer, Hash)>] LoyaltiesEarningRulesGetResponseBody data, response status code and response headers + private def get_earning_rule_with_http_info(campaign_id, earning_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.get_earning_rule ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.get_earning_rule" + end + # verify the required parameter 'earning_rule_id' is set + if @api_client.config.client_side_validation && earning_rule_id.nil? + fail ArgumentError, "Missing the required parameter 'earning_rule_id' when calling LoyaltiesApi.get_earning_rule" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/earning-rules/{earningRuleId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'earningRuleId' + '}', CGI.escape(earning_rule_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesEarningRulesGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.get_earning_rule", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#get_earning_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Loyalty Tier + # Retrieve a loyalty tier from a loyalty campaign by the loyalty tier ID. + # @param campaign_id [String] Unique loyalty campaign ID or name. + # @param loyalty_tier_id [String] Unique loyalty tier ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesTiersGetResponseBody] + def get_loyalty_tier(campaign_id, loyalty_tier_id, opts = {}) + data, _status_code, _headers = get_loyalty_tier_with_http_info(campaign_id, loyalty_tier_id, opts) + data + end + + # Get Loyalty Tier + # Retrieve a loyalty tier from a loyalty campaign by the loyalty tier ID. + # @param campaign_id [String] Unique loyalty campaign ID or name. + # @param loyalty_tier_id [String] Unique loyalty tier ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesTiersGetResponseBody, Integer, Hash)>] LoyaltiesTiersGetResponseBody data, response status code and response headers + private def get_loyalty_tier_with_http_info(campaign_id, loyalty_tier_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.get_loyalty_tier ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.get_loyalty_tier" + end + # verify the required parameter 'loyalty_tier_id' is set + if @api_client.config.client_side_validation && loyalty_tier_id.nil? + fail ArgumentError, "Missing the required parameter 'loyalty_tier_id' when calling LoyaltiesApi.get_loyalty_tier" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/tiers/{loyaltyTierId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'loyaltyTierId' + '}', CGI.escape(loyalty_tier_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesTiersGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.get_loyalty_tier", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#get_loyalty_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Reward Assignment + # Retrieve specific reward assignment. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] Unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesRewardAssignmentsGetResponseBody] + def get_reward_assignment1(campaign_id, assignment_id, opts = {}) + data, _status_code, _headers = get_reward_assignment1_with_http_info(campaign_id, assignment_id, opts) + data + end + + # Get Reward Assignment + # Retrieve specific reward assignment. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] Unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesRewardAssignmentsGetResponseBody, Integer, Hash)>] LoyaltiesRewardAssignmentsGetResponseBody data, response status code and response headers + private def get_reward_assignment1_with_http_info(campaign_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.get_reward_assignment1 ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.get_reward_assignment1" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling LoyaltiesApi.get_reward_assignment1" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/reward-assignments/{assignmentId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesRewardAssignmentsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.get_reward_assignment1", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#get_reward_assignment1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Reward Assignment + # Retrieve specific reward assignment. 📘 Alternative endpoint This endpoint is an alternative to this endpoint. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesRewardsGetResponseBody] + def get_reward_assignment2(campaign_id, assignment_id, opts = {}) + data, _status_code, _headers = get_reward_assignment2_with_http_info(campaign_id, assignment_id, opts) + data + end + + # Get Reward Assignment + # Retrieve specific reward assignment. 📘 Alternative endpoint This endpoint is an alternative to this endpoint. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesRewardsGetResponseBody, Integer, Hash)>] LoyaltiesRewardsGetResponseBody data, response status code and response headers + private def get_reward_assignment2_with_http_info(campaign_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.get_reward_assignment2 ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.get_reward_assignment2" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling LoyaltiesApi.get_reward_assignment2" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/rewards/{assignmentId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesRewardsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.get_reward_assignment2", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#get_reward_assignment2\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Reward Details + # Get reward details in the context of a loyalty campaign and reward assignment ID. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] Unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesRewardAssignmentsRewardGetResponseBody] + def get_reward_details(campaign_id, assignment_id, opts = {}) + data, _status_code, _headers = get_reward_details_with_http_info(campaign_id, assignment_id, opts) + data + end + + # Get Reward Details + # Get reward details in the context of a loyalty campaign and reward assignment ID. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param assignment_id [String] Unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesRewardAssignmentsRewardGetResponseBody, Integer, Hash)>] LoyaltiesRewardAssignmentsRewardGetResponseBody data, response status code and response headers + private def get_reward_details_with_http_info(campaign_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.get_reward_details ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.get_reward_details" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling LoyaltiesApi.get_reward_details" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/reward-assignments/{assignmentId}/reward'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesRewardAssignmentsRewardGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.get_reward_details", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#get_reward_details\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Loyalty Card Transactions + # Retrieve transaction data related to point movements for a specific loyalty card. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to retrieve transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [LoyaltiesMembersTransactionsListResponseBody] + def list_loyalty_card_transactions(member_id, opts = {}) + data, _status_code, _headers = list_loyalty_card_transactions_with_http_info(member_id, opts) + data + end + + # List Loyalty Card Transactions + # Retrieve transaction data related to point movements for a specific loyalty card. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to retrieve transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [Array<(LoyaltiesMembersTransactionsListResponseBody, Integer, Hash)>] LoyaltiesMembersTransactionsListResponseBody data, response status code and response headers + private def list_loyalty_card_transactions_with_http_info(member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_loyalty_card_transactions ...' + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.list_loyalty_card_transactions" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_card_transactions, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_card_transactions, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling LoyaltiesApi.list_loyalty_card_transactions, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/loyalties/members/{memberId}/transactions'.sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersTransactionsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_loyalty_card_transactions", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_loyalty_card_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Loyalty Card Transactions + # Retrieve transaction data related to point movements for a specific loyalty card. + # @param campaign_id [String] A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to return. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to retrieve transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [LoyaltiesMembersTransactionsListResponseBody] + def list_loyalty_card_transactions1(campaign_id, member_id, opts = {}) + data, _status_code, _headers = list_loyalty_card_transactions1_with_http_info(campaign_id, member_id, opts) + data + end + + # List Loyalty Card Transactions + # Retrieve transaction data related to point movements for a specific loyalty card. + # @param campaign_id [String] A unique identifier of the loyalty campaign containing the voucher whose transactions you would like to return. + # @param member_id [String] A unique code identifying the loyalty card that you are looking to retrieve transaction data for. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [Array<(LoyaltiesMembersTransactionsListResponseBody, Integer, Hash)>] LoyaltiesMembersTransactionsListResponseBody data, response status code and response headers + private def list_loyalty_card_transactions1_with_http_info(campaign_id, member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_loyalty_card_transactions1 ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.list_loyalty_card_transactions1" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.list_loyalty_card_transactions1" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_card_transactions1, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_card_transactions1, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling LoyaltiesApi.list_loyalty_card_transactions1, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/loyalties/{campaignId}/members/{memberId}/transactions'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersTransactionsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_loyalty_card_transactions1", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_loyalty_card_transactions1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Loyalty Tier Earning Rules + # Retrieve available earning rules for a given tier and the calculation method for earning points. + # @param campaign_id [String] Unique campaign ID or name. + # @param loyalty_tier_id [String] Unique loyalty tier ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [LoyaltiesTiersEarningRulesListResponseBody] + def list_loyalty_tier_earning_rules(campaign_id, loyalty_tier_id, opts = {}) + data, _status_code, _headers = list_loyalty_tier_earning_rules_with_http_info(campaign_id, loyalty_tier_id, opts) + data + end + + # List Loyalty Tier Earning Rules + # Retrieve available earning rules for a given tier and the calculation method for earning points. + # @param campaign_id [String] Unique campaign ID or name. + # @param loyalty_tier_id [String] Unique loyalty tier ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [Array<(LoyaltiesTiersEarningRulesListResponseBody, Integer, Hash)>] LoyaltiesTiersEarningRulesListResponseBody data, response status code and response headers + private def list_loyalty_tier_earning_rules_with_http_info(campaign_id, loyalty_tier_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_loyalty_tier_earning_rules ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.list_loyalty_tier_earning_rules" + end + # verify the required parameter 'loyalty_tier_id' is set + if @api_client.config.client_side_validation && loyalty_tier_id.nil? + fail ArgumentError, "Missing the required parameter 'loyalty_tier_id' when calling LoyaltiesApi.list_loyalty_tier_earning_rules" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_tier_earning_rules, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_tier_earning_rules, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling LoyaltiesApi.list_loyalty_tier_earning_rules, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/earning-rules'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'loyaltyTierId' + '}', CGI.escape(loyalty_tier_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesTiersEarningRulesListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_loyalty_tier_earning_rules", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_loyalty_tier_earning_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Loyalty Tier Rewards + # Get available rewards for a given tier. + # @param campaign_id [String] Unique campaign ID or name. + # @param loyalty_tier_id [String] Unique loyalty tier ID. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesTiersRewardsListResponseBody] + def list_loyalty_tier_rewards(campaign_id, loyalty_tier_id, opts = {}) + data, _status_code, _headers = list_loyalty_tier_rewards_with_http_info(campaign_id, loyalty_tier_id, opts) + data + end + + # List Loyalty Tier Rewards + # Get available rewards for a given tier. + # @param campaign_id [String] Unique campaign ID or name. + # @param loyalty_tier_id [String] Unique loyalty tier ID. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesTiersRewardsListResponseBody, Integer, Hash)>] LoyaltiesTiersRewardsListResponseBody data, response status code and response headers + private def list_loyalty_tier_rewards_with_http_info(campaign_id, loyalty_tier_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_loyalty_tier_rewards ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.list_loyalty_tier_rewards" + end + # verify the required parameter 'loyalty_tier_id' is set + if @api_client.config.client_side_validation && loyalty_tier_id.nil? + fail ArgumentError, "Missing the required parameter 'loyalty_tier_id' when calling LoyaltiesApi.list_loyalty_tier_rewards" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/tiers/{loyaltyTierId}/rewards'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'loyaltyTierId' + '}', CGI.escape(loyalty_tier_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesTiersRewardsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_loyalty_tier_rewards", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_loyalty_tier_rewards\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Loyalty Tiers + # Retrieve a list of loyalty tiers which were added to the loyalty program. + # @param campaign_id [String] Unique loyalty campaign ID or name. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [ParameterOrderListLoyaltyTiers] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [LoyaltiesTiersListResponseBody] + def list_loyalty_tiers(campaign_id, opts = {}) + data, _status_code, _headers = list_loyalty_tiers_with_http_info(campaign_id, opts) + data + end + + # List Loyalty Tiers + # Retrieve a list of loyalty tiers which were added to the loyalty program. + # @param campaign_id [String] Unique loyalty campaign ID or name. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [ParameterOrderListLoyaltyTiers] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [Array<(LoyaltiesTiersListResponseBody, Integer, Hash)>] LoyaltiesTiersListResponseBody data, response status code and response headers + private def list_loyalty_tiers_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_loyalty_tiers ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.list_loyalty_tiers" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_tiers, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_loyalty_tiers, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/v1/loyalties/{campaignId}/tiers'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesTiersListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_loyalty_tiers", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_loyalty_tiers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Member's Loyalty Tiers + # Retrieve member tiers using the loyalty card ID. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @return [LoyaltiesMembersTiersListResponseBody] + def list_member_loyalty_tier(member_id, opts = {}) + data, _status_code, _headers = list_member_loyalty_tier_with_http_info(member_id, opts) + data + end + + # List Member's Loyalty Tiers + # Retrieve member tiers using the loyalty card ID. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @return [Array<(LoyaltiesMembersTiersListResponseBody, Integer, Hash)>] LoyaltiesMembersTiersListResponseBody data, response status code and response headers + private def list_member_loyalty_tier_with_http_info(member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_member_loyalty_tier ...' + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.list_member_loyalty_tier" + end + # resource path + local_var_path = '/v1/loyalties/members/{memberId}/tiers'.sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersTiersListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_member_loyalty_tier", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_member_loyalty_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Member Rewards + # Retrieves the list of rewards that the given customer (identified by member_id, which is a loyalty card assigned to a particular customer) **can get in exchange for loyalty points**. You can use the affordable_only parameter to limit the results to rewards that the customer can actually afford (only rewards whose price in points is not higher than the loyalty points balance on a loyalty card). Please note that rewards that are disabled (i.e. set to Not Available in the Dashboard) for a given loyalty tier reward mapping will not be returned in this endpoint. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :affordable_only Limit the results to rewards that the customer can actually afford (only rewards whose price in points is not higher than the loyalty points balance on a loyalty card). Set this flag to true to return rewards which the customer can actually afford. + # @return [LoyaltiesMembersRewardsListResponseBody] + def list_member_rewards(member_id, opts = {}) + data, _status_code, _headers = list_member_rewards_with_http_info(member_id, opts) + data + end + + # List Member Rewards + # Retrieves the list of rewards that the given customer (identified by member_id, which is a loyalty card assigned to a particular customer) **can get in exchange for loyalty points**. You can use the affordable_only parameter to limit the results to rewards that the customer can actually afford (only rewards whose price in points is not higher than the loyalty points balance on a loyalty card). Please note that rewards that are disabled (i.e. set to Not Available in the Dashboard) for a given loyalty tier reward mapping will not be returned in this endpoint. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :affordable_only Limit the results to rewards that the customer can actually afford (only rewards whose price in points is not higher than the loyalty points balance on a loyalty card). Set this flag to true to return rewards which the customer can actually afford. + # @return [Array<(LoyaltiesMembersRewardsListResponseBody, Integer, Hash)>] LoyaltiesMembersRewardsListResponseBody data, response status code and response headers + private def list_member_rewards_with_http_info(member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_member_rewards ...' + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.list_member_rewards" + end + # resource path + local_var_path = '/v1/loyalties/members/{memberId}/rewards'.sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'affordable_only'] = opts[:'affordable_only'] if !opts[:'affordable_only'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersRewardsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_member_rewards", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_member_rewards\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Points Expiration + # Retrieve loyalty point expiration buckets for a given loyalty card. Expired point buckets are not returned in this endpoint. You can use the Exports API to retrieve a list of both ACTIVE and EXPIRED point buckets. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param member_id [String] Loyalty card code. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [LoyaltiesMembersPointsExpirationListResponseBody] + def list_points_expiration(campaign_id, member_id, opts = {}) + data, _status_code, _headers = list_points_expiration_with_http_info(campaign_id, member_id, opts) + data + end + + # Get Points Expiration + # Retrieve loyalty point expiration buckets for a given loyalty card. Expired point buckets are not returned in this endpoint. You can use the Exports API to retrieve a list of both ACTIVE and EXPIRED point buckets. + # @param campaign_id [String] The campaign ID or name of the loyalty campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty%20Campaign. + # @param member_id [String] Loyalty card code. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [Array<(LoyaltiesMembersPointsExpirationListResponseBody, Integer, Hash)>] LoyaltiesMembersPointsExpirationListResponseBody data, response status code and response headers + private def list_points_expiration_with_http_info(campaign_id, member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.list_points_expiration ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.list_points_expiration" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.list_points_expiration" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_points_expiration, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling LoyaltiesApi.list_points_expiration, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling LoyaltiesApi.list_points_expiration, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/loyalties/{campaignId}/members/{memberId}/points-expiration'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersPointsExpirationListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.list_points_expiration", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LoyaltiesApi#list_points_expiration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Redeem Reward + # 📘 Alternative endpoint This endpoint is an alternative to this endpoint. The URL was re-designed to allow you to redeem a reward without having to provide the campaignId as a path parameter. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersRedemptionRedeemRequestBody] :loyalties_members_redemption_redeem_request_body Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. + # @return [LoyaltiesMembersRedemptionRedeemResponseBody] + def redeem_reward(member_id, opts = {}) + data, _status_code, _headers = redeem_reward_with_http_info(member_id, opts) + data + end + + # Redeem Reward + # 📘 Alternative endpoint This endpoint is an alternative to this endpoint. The URL was re-designed to allow you to redeem a reward without having to provide the campaignId as a path parameter. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersRedemptionRedeemRequestBody] :loyalties_members_redemption_redeem_request_body Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. + # @return [Array<(LoyaltiesMembersRedemptionRedeemResponseBody, Integer, Hash)>] LoyaltiesMembersRedemptionRedeemResponseBody data, response status code and response headers + private def redeem_reward_with_http_info(member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.redeem_reward ...' + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.redeem_reward" + end + # resource path + local_var_path = '/v1/loyalties/members/{memberId}/redemption'.sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_members_redemption_redeem_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersRedemptionRedeemResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.redeem_reward", + :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: LoyaltiesApi#redeem_reward\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Redeem Reward + # Exchange points from a loyalty card for a specified reward. This API method returns an assigned award in the response. It means that if a requesting customer gets a coupon code with a discount for the next order, that discount code will be visible in response as part of the reward object definition. + # @param campaign_id [String] Unique campaign ID. + # @param member_id [String] A code that identifies the loyalty card. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersRedemptionRedeemRequestBody] :loyalties_members_redemption_redeem_request_body Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. + # @return [LoyaltiesMembersRedemptionRedeemResponseBody] + def redeem_reward1(campaign_id, member_id, opts = {}) + data, _status_code, _headers = redeem_reward1_with_http_info(campaign_id, member_id, opts) + data + end + + # Redeem Reward + # Exchange points from a loyalty card for a specified reward. This API method returns an assigned award in the response. It means that if a requesting customer gets a coupon code with a discount for the next order, that discount code will be visible in response as part of the reward object definition. + # @param campaign_id [String] Unique campaign ID. + # @param member_id [String] A code that identifies the loyalty card. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersRedemptionRedeemRequestBody] :loyalties_members_redemption_redeem_request_body Specify the reward to be redeemed. In case of a pay with points reward, specify the order and the number of points to be applied to the order. Please note that if you do not specify the amount of points, the application will default to applying the number of points to pay for the remainder of the order. If the limit of available points on the card is reached, then only the available points on the card will be applied to the order. + # @return [Array<(LoyaltiesMembersRedemptionRedeemResponseBody, Integer, Hash)>] LoyaltiesMembersRedemptionRedeemResponseBody data, response status code and response headers + private def redeem_reward1_with_http_info(campaign_id, member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.redeem_reward1 ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.redeem_reward1" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.redeem_reward1" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/members/{memberId}/redemption'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_members_redemption_redeem_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersRedemptionRedeemResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.redeem_reward1", + :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: LoyaltiesApi#redeem_reward1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Transfer Loyalty Points + # Transfer points between different loyalty cards. You need to provide the campaign ID and the loyalty card ID you want the points to be transferred to as path parameters in the URL. In the request body, you provide the loyalty cards you want the points to be transferred from and the number of points to transfer from each card. + # @param campaign_id [String] A unique identifier of the loyalty campaign containing the voucher to which the loyalty points will be sent (destination). + # @param member_id [String] A unique code identifying the loyalty card to which the user wants to transfer loyalty points (destination). + # @param [Hash] opts the optional parameters + # @option opts [Array] :loyalties_transfer_points Provide the loyalty cards you want the points to be transferred from and the number of points to transfer from each card. + # @return [LoyaltiesMembersTransfersCreateResponseBody] + def transfer_points(campaign_id, member_id, opts = {}) + data, _status_code, _headers = transfer_points_with_http_info(campaign_id, member_id, opts) + data + end + + # Transfer Loyalty Points + # Transfer points between different loyalty cards. You need to provide the campaign ID and the loyalty card ID you want the points to be transferred to as path parameters in the URL. In the request body, you provide the loyalty cards you want the points to be transferred from and the number of points to transfer from each card. + # @param campaign_id [String] A unique identifier of the loyalty campaign containing the voucher to which the loyalty points will be sent (destination). + # @param member_id [String] A unique code identifying the loyalty card to which the user wants to transfer loyalty points (destination). + # @param [Hash] opts the optional parameters + # @option opts [Array] :loyalties_transfer_points Provide the loyalty cards you want the points to be transferred from and the number of points to transfer from each card. + # @return [Array<(LoyaltiesMembersTransfersCreateResponseBody, Integer, Hash)>] LoyaltiesMembersTransfersCreateResponseBody data, response status code and response headers + private def transfer_points_with_http_info(campaign_id, member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.transfer_points ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.transfer_points" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.transfer_points" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/members/{memberId}/transfers'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_transfer_points']) + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersTransfersCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.transfer_points", + :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: LoyaltiesApi#transfer_points\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Add or Remove Loyalty Card Balance + # This method gives adds or removes balance to an existing loyalty card. The removal of points will consume the points that expire the soonest. 📘 Alternative endpoint This endpoint is an alternative to this endpoint. The URL was re-designed to allow you to add or remove loyalty card balance without having to provide the campaignId as a path parameter. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersBalanceUpdateRequestBody] :loyalties_members_balance_update_request_body Specify the point adjustment along with the expiration mechanism. + # @return [LoyaltiesMembersBalanceUpdateResponseBody] + def update_loyalty_card_balance(member_id, opts = {}) + data, _status_code, _headers = update_loyalty_card_balance_with_http_info(member_id, opts) + data + end + + # Add or Remove Loyalty Card Balance + # This method gives adds or removes balance to an existing loyalty card. The removal of points will consume the points that expire the soonest. 📘 Alternative endpoint This endpoint is an alternative to this endpoint. The URL was re-designed to allow you to add or remove loyalty card balance without having to provide the campaignId as a path parameter. + # @param member_id [String] Unique loyalty card assigned to a particular customer. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersBalanceUpdateRequestBody] :loyalties_members_balance_update_request_body Specify the point adjustment along with the expiration mechanism. + # @return [Array<(LoyaltiesMembersBalanceUpdateResponseBody, Integer, Hash)>] LoyaltiesMembersBalanceUpdateResponseBody data, response status code and response headers + private def update_loyalty_card_balance_with_http_info(member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.update_loyalty_card_balance ...' + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.update_loyalty_card_balance" + end + # resource path + local_var_path = '/v1/loyalties/members/{memberId}/balance'.sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_members_balance_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersBalanceUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.update_loyalty_card_balance", + :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: LoyaltiesApi#update_loyalty_card_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Add or Remove Loyalty Card Balance + # This method adds or removes balance to an existing loyalty card. The removal of points will consume the points that expire the soonest. + # @param campaign_id [String] Unique campaign ID. + # @param member_id [String] A code that identifies the loyalty card. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersBalanceUpdateRequestBody] :loyalties_members_balance_update_request_body Specify the point adjustment along with the expiration mechanism. + # @return [LoyaltiesMembersBalanceUpdateResponseBody] + def update_loyalty_card_balance1(campaign_id, member_id, opts = {}) + data, _status_code, _headers = update_loyalty_card_balance1_with_http_info(campaign_id, member_id, opts) + data + end + + # Add or Remove Loyalty Card Balance + # This method adds or removes balance to an existing loyalty card. The removal of points will consume the points that expire the soonest. + # @param campaign_id [String] Unique campaign ID. + # @param member_id [String] A code that identifies the loyalty card. + # @param [Hash] opts the optional parameters + # @option opts [LoyaltiesMembersBalanceUpdateRequestBody] :loyalties_members_balance_update_request_body Specify the point adjustment along with the expiration mechanism. + # @return [Array<(LoyaltiesMembersBalanceUpdateResponseBody, Integer, Hash)>] LoyaltiesMembersBalanceUpdateResponseBody data, response status code and response headers + private def update_loyalty_card_balance1_with_http_info(campaign_id, member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LoyaltiesApi.update_loyalty_card_balance1 ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling LoyaltiesApi.update_loyalty_card_balance1" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling LoyaltiesApi.update_loyalty_card_balance1" + end + # resource path + local_var_path = '/v1/loyalties/{campaignId}/members/{memberId}/balance'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'loyalties_members_balance_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'LoyaltiesMembersBalanceUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"LoyaltiesApi.update_loyalty_card_balance1", + :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: LoyaltiesApi#update_loyalty_card_balance1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/orders_api.rb b/lib/VoucherifySdk/api/orders_api.rb new file mode 100644 index 00000000..815c4249 --- /dev/null +++ b/lib/VoucherifySdk/api/orders_api.rb @@ -0,0 +1,425 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class OrdersApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Order + # Creates an order object and triggers an order creation event. 📘 Upsert Mode If you pass an id or a source_id that already exists in the order database, Voucherify will return a related order object with updated fields. + # @param [Hash] opts the optional parameters + # @option opts [OrdersCreateRequestBody] :orders_create_request_body Specify the order parameters. + # @return [OrdersCreateResponseBody] + def create_order(opts = {}) + data, _status_code, _headers = create_order_with_http_info(opts) + data + end + + # Create Order + # Creates an order object and triggers an order creation event. 📘 Upsert Mode If you pass an id or a source_id that already exists in the order database, Voucherify will return a related order object with updated fields. + # @param [Hash] opts the optional parameters + # @option opts [OrdersCreateRequestBody] :orders_create_request_body Specify the order parameters. + # @return [Array<(OrdersCreateResponseBody, Integer, Hash)>] OrdersCreateResponseBody data, response status code and response headers + private def create_order_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrdersApi.create_order ...' + end + # resource path + local_var_path = '/v1/orders' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'orders_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'OrdersCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"OrdersApi.create_order", + :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: OrdersApi#create_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Create Orders Export + # Creates a downloadable CSV file containing a list of orders. The parameters listed in the payload resembles headers in the CSV file. To include a parameter to the file, add it to the parameters.fields object in the request body. The available filters are all order object attributes. Additionally, any metadata defined in the metadata schema can be exported. Passing an empty JSON will generate a file containing three default fields: id, source_id, and status. The fields array is an array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields: + # @param [Hash] opts the optional parameters + # @option opts [OrdersExportCreateRequestBody] :orders_export_create_request_body Specify which order parameters you would like to export. + # @return [OrdersExportCreateResponseBody] + def create_order_export(opts = {}) + data, _status_code, _headers = create_order_export_with_http_info(opts) + data + end + + # Create Orders Export + # Creates a downloadable CSV file containing a list of orders. The parameters listed in the payload resembles headers in the CSV file. To include a parameter to the file, add it to the parameters.fields object in the request body. The available filters are all order object attributes. Additionally, any metadata defined in the metadata schema can be exported. Passing an empty JSON will generate a file containing three default fields: id, source_id, and status. The fields array is an array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields: + # @param [Hash] opts the optional parameters + # @option opts [OrdersExportCreateRequestBody] :orders_export_create_request_body Specify which order parameters you would like to export. + # @return [Array<(OrdersExportCreateResponseBody, Integer, Hash)>] OrdersExportCreateResponseBody data, response status code and response headers + private def create_order_export_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrdersApi.create_order_export ...' + end + # resource path + local_var_path = '/v1/orders/export' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'orders_export_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'OrdersExportCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"OrdersApi.create_order_export", + :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: OrdersApi#create_order_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Order + # Retrieve an order. + # @param order_id [String] Unique Voucherify order ID or order source ID. + # @param [Hash] opts the optional parameters + # @return [OrdersGetResponseBody] + def get_order(order_id, opts = {}) + data, _status_code, _headers = get_order_with_http_info(order_id, opts) + data + end + + # Get Order + # Retrieve an order. + # @param order_id [String] Unique Voucherify order ID or order source ID. + # @param [Hash] opts the optional parameters + # @return [Array<(OrdersGetResponseBody, Integer, Hash)>] OrdersGetResponseBody data, response status code and response headers + private def get_order_with_http_info(order_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrdersApi.get_order ...' + end + # verify the required parameter 'order_id' is set + if @api_client.config.client_side_validation && order_id.nil? + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrdersApi.get_order" + end + # resource path + local_var_path = '/v1/orders/{orderId}'.sub('{' + 'orderId' + '}', CGI.escape(order_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'OrdersGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"OrdersApi.get_order", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OrdersApi#get_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import Orders + # 🚧 Historical orders This endpoint should only be used to import historical orders into Voucherify. For on-going synchronization, the create order and update order endpoints should be used. This is critical because this endpoint does not store events or launch distributions. # Limitations ## Import volume There can be only a single on-going order import per tenant per project at a given time. The user can schedule more imports but those extra imports will be scheduled to run in sequence one by one. ## Maximum count of orders in single import There is a 2000 limit but we might decide to change it to a lower / higher value at any given time depending if we find this value is too high or too low with time. # Notifications There are no notifications on the Dashboard because this import is launched via the API. # Triggered actions If you import orders with customers, then a logic will be scheduled responsible for placing these customers into segments and refreshing the segments summary. Consequently, this update will trigger - **customers entering into segments** - **distributions** based on any rules tied to customer entering segment(s) - **earning rules** based on the customer entering segment(s) # What is not triggered 1. No webhooks are triggered during the import of orders - for both orders and upserted products / skus. 2. Distributions based on Order Update, Order Paid, Order Created and Order Cancelled. In other words if you have a distribution based on Order Paid and you import an order with a PAID status, the distribution is not going to be triggered. 3. No events are created during the import of orders - for both orders and upserted products / skus. In other words you wont see any events in the Activity tab in the Dashboard such as Order created or Order paid. If you are additionally upserting products / skus, then you wont see the Product created events listed, etc. 4. Earning rules based on Order Paid wont be triggered. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [Array] :orders_import_create_request_body_item The request body is sent in the form of an array of order objects. + # @return [OrdersImportCreateResponseBody] + def import_orders(opts = {}) + data, _status_code, _headers = import_orders_with_http_info(opts) + data + end + + # Import Orders + # 🚧 Historical orders This endpoint should only be used to import historical orders into Voucherify. For on-going synchronization, the create order and update order endpoints should be used. This is critical because this endpoint does not store events or launch distributions. # Limitations ## Import volume There can be only a single on-going order import per tenant per project at a given time. The user can schedule more imports but those extra imports will be scheduled to run in sequence one by one. ## Maximum count of orders in single import There is a 2000 limit but we might decide to change it to a lower / higher value at any given time depending if we find this value is too high or too low with time. # Notifications There are no notifications on the Dashboard because this import is launched via the API. # Triggered actions If you import orders with customers, then a logic will be scheduled responsible for placing these customers into segments and refreshing the segments summary. Consequently, this update will trigger - **customers entering into segments** - **distributions** based on any rules tied to customer entering segment(s) - **earning rules** based on the customer entering segment(s) # What is not triggered 1. No webhooks are triggered during the import of orders - for both orders and upserted products / skus. 2. Distributions based on Order Update, Order Paid, Order Created and Order Cancelled. In other words if you have a distribution based on Order Paid and you import an order with a PAID status, the distribution is not going to be triggered. 3. No events are created during the import of orders - for both orders and upserted products / skus. In other words you wont see any events in the Activity tab in the Dashboard such as Order created or Order paid. If you are additionally upserting products / skus, then you wont see the Product created events listed, etc. 4. Earning rules based on Order Paid wont be triggered. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [Array] :orders_import_create_request_body_item The request body is sent in the form of an array of order objects. + # @return [Array<(OrdersImportCreateResponseBody, Integer, Hash)>] OrdersImportCreateResponseBody data, response status code and response headers + private def import_orders_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrdersApi.import_orders ...' + end + # resource path + local_var_path = '/v1/orders/import' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'orders_import_create_request_body_item']) + + # return_type + return_type = opts[:debug_return_type] || 'OrdersImportCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"OrdersApi.import_orders", + :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: OrdersApi#import_orders\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Orders + # Returns a list of orders. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListOrders] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [OrdersListResponseBody] + def list_orders(opts = {}) + data, _status_code, _headers = list_orders_with_http_info(opts) + data + end + + # List Orders + # Returns a list of orders. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListOrders] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [Array<(OrdersListResponseBody, Integer, Hash)>] OrdersListResponseBody data, response status code and response headers + private def list_orders_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrdersApi.list_orders ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling OrdersApi.list_orders, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling OrdersApi.list_orders, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling OrdersApi.list_orders, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/orders' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'OrdersListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"OrdersApi.list_orders", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OrdersApi#list_orders\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Order + # Updates the specified order by setting the values of the parameters passed in the request body. Any parameters not provided will be left unchanged. + # @param order_id [String] Unique Voucherify order ID or order source ID. + # @param [Hash] opts the optional parameters + # @option opts [OrdersUpdateRequestBody] :orders_update_request_body Specify the parameters of the order that are to be updated. + # @return [OrdersUpdateResponseBody] + def update_order(order_id, opts = {}) + data, _status_code, _headers = update_order_with_http_info(order_id, opts) + data + end + + # Update Order + # Updates the specified order by setting the values of the parameters passed in the request body. Any parameters not provided will be left unchanged. + # @param order_id [String] Unique Voucherify order ID or order source ID. + # @param [Hash] opts the optional parameters + # @option opts [OrdersUpdateRequestBody] :orders_update_request_body Specify the parameters of the order that are to be updated. + # @return [Array<(OrdersUpdateResponseBody, Integer, Hash)>] OrdersUpdateResponseBody data, response status code and response headers + private def update_order_with_http_info(order_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrdersApi.update_order ...' + end + # verify the required parameter 'order_id' is set + if @api_client.config.client_side_validation && order_id.nil? + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrdersApi.update_order" + end + # resource path + local_var_path = '/v1/orders/{orderId}'.sub('{' + 'orderId' + '}', CGI.escape(order_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'orders_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'OrdersUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"OrdersApi.update_order", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OrdersApi#update_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/product_collections_api.rb b/lib/VoucherifySdk/api/product_collections_api.rb new file mode 100644 index 00000000..cb0ba190 --- /dev/null +++ b/lib/VoucherifySdk/api/product_collections_api.rb @@ -0,0 +1,375 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class ProductCollectionsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Product Collection + # This method creates a new product collection. + # @param [Hash] opts the optional parameters + # @option opts [ProductCollectionsCreateRequestBody] :product_collections_create_request_body + # @return [ProductCollectionsCreateResponseBody] + def create_product_collection(opts = {}) + data, _status_code, _headers = create_product_collection_with_http_info(opts) + data + end + + # Create Product Collection + # This method creates a new product collection. + # @param [Hash] opts the optional parameters + # @option opts [ProductCollectionsCreateRequestBody] :product_collections_create_request_body + # @return [Array<(ProductCollectionsCreateResponseBody, Integer, Hash)>] ProductCollectionsCreateResponseBody data, response status code and response headers + private def create_product_collection_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.create_product_collection ...' + end + # resource path + local_var_path = '/v1/product-collections' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'product_collections_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ProductCollectionsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductCollectionsApi.create_product_collection", + :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: ProductCollectionsApi#create_product_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Product Collection + # This method deletes a product collection. + # @param product_collection_id [String] A unique product collection ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_product_collection(product_collection_id, opts = {}) + delete_product_collection_with_http_info(product_collection_id, opts) + nil + end + + # Delete Product Collection + # This method deletes a product collection. + # @param product_collection_id [String] A unique product collection ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_product_collection_with_http_info(product_collection_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.delete_product_collection ...' + end + # verify the required parameter 'product_collection_id' is set + if @api_client.config.client_side_validation && product_collection_id.nil? + fail ArgumentError, "Missing the required parameter 'product_collection_id' when calling ProductCollectionsApi.delete_product_collection" + end + # resource path + local_var_path = '/v1/product-collections/{productCollectionId}'.sub('{' + 'productCollectionId' + '}', CGI.escape(product_collection_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductCollectionsApi.delete_product_collection", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductCollectionsApi#delete_product_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Product Collection + # Retrieves the product collection. + # @param product_collection_id [String] A unique product collection ID. + # @param [Hash] opts the optional parameters + # @return [ProductCollectionsGetResponseBody] + def get_product_collection(product_collection_id, opts = {}) + data, _status_code, _headers = get_product_collection_with_http_info(product_collection_id, opts) + data + end + + # Get Product Collection + # Retrieves the product collection. + # @param product_collection_id [String] A unique product collection ID. + # @param [Hash] opts the optional parameters + # @return [Array<(ProductCollectionsGetResponseBody, Integer, Hash)>] ProductCollectionsGetResponseBody data, response status code and response headers + private def get_product_collection_with_http_info(product_collection_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.get_product_collection ...' + end + # verify the required parameter 'product_collection_id' is set + if @api_client.config.client_side_validation && product_collection_id.nil? + fail ArgumentError, "Missing the required parameter 'product_collection_id' when calling ProductCollectionsApi.get_product_collection" + end + # resource path + local_var_path = '/v1/product-collections/{productCollectionId}'.sub('{' + 'productCollectionId' + '}', CGI.escape(product_collection_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ProductCollectionsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductCollectionsApi.get_product_collection", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductCollectionsApi#get_product_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Product Collections + # This method returns a list of product collections. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [ProductCollectionsListResponseBody] + def list_product_collections(opts = {}) + data, _status_code, _headers = list_product_collections_with_http_info(opts) + data + end + + # List Product Collections + # This method returns a list of product collections. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [Array<(ProductCollectionsListResponseBody, Integer, Hash)>] ProductCollectionsListResponseBody data, response status code and response headers + private def list_product_collections_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.list_product_collections ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_product_collections, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_product_collections, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ProductCollectionsApi.list_product_collections, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/product-collections' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ProductCollectionsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductCollectionsApi.list_product_collections", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductCollectionsApi#list_product_collections\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Products in Collection + # Retrieves list of products from a product collection; works for both dynamic and static product collections. + # @param product_collection_id [String] Unique product collection ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :starting_after Timestamp representing the date and time to use in starting_after cursor to get more data. Represented in ISO 8601 format. + # @return [ProductCollectionsProductsListResponseBody] + def list_products_in_collection(product_collection_id, opts = {}) + data, _status_code, _headers = list_products_in_collection_with_http_info(product_collection_id, opts) + data + end + + # List Products in Collection + # Retrieves list of products from a product collection; works for both dynamic and static product collections. + # @param product_collection_id [String] Unique product collection ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :starting_after Timestamp representing the date and time to use in starting_after cursor to get more data. Represented in ISO 8601 format. + # @return [Array<(ProductCollectionsProductsListResponseBody, Integer, Hash)>] ProductCollectionsProductsListResponseBody data, response status code and response headers + private def list_products_in_collection_with_http_info(product_collection_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductCollectionsApi.list_products_in_collection ...' + end + # verify the required parameter 'product_collection_id' is set + if @api_client.config.client_side_validation && product_collection_id.nil? + fail ArgumentError, "Missing the required parameter 'product_collection_id' when calling ProductCollectionsApi.list_products_in_collection" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_products_in_collection, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductCollectionsApi.list_products_in_collection, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ProductCollectionsApi.list_products_in_collection, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/product-collections/{productCollectionId}/products'.sub('{' + 'productCollectionId' + '}', CGI.escape(product_collection_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'starting_after'] = opts[:'starting_after'] if !opts[:'starting_after'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ProductCollectionsProductsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductCollectionsApi.list_products_in_collection", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductCollectionsApi#list_products_in_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/products_api.rb b/lib/VoucherifySdk/api/products_api.rb new file mode 100644 index 00000000..6d3352b0 --- /dev/null +++ b/lib/VoucherifySdk/api/products_api.rb @@ -0,0 +1,1002 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class ProductsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Product + # Creates a product object. 📘 Upsert Mode If you pass an id or a source_id that already exists in the product database, Voucherify will return a related product object with updated fields. + # @param [Hash] opts the optional parameters + # @option opts [ProductsCreateRequestBody] :products_create_request_body Specify the product parameters. + # @return [ProductsCreateResponseBody] + def create_product(opts = {}) + data, _status_code, _headers = create_product_with_http_info(opts) + data + end + + # Create Product + # Creates a product object. 📘 Upsert Mode If you pass an id or a source_id that already exists in the product database, Voucherify will return a related product object with updated fields. + # @param [Hash] opts the optional parameters + # @option opts [ProductsCreateRequestBody] :products_create_request_body Specify the product parameters. + # @return [Array<(ProductsCreateResponseBody, Integer, Hash)>] ProductsCreateResponseBody data, response status code and response headers + private def create_product_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.create_product ...' + end + # resource path + local_var_path = '/v1/products' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'products_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ProductsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.create_product", + :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: ProductsApi#create_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Create SKU + # This method adds product variants to a created product. 📘 Upsert Mode If you pass an id or a source_id that already exists in the sku database, Voucherify will return a related sku object with updated fields. + # @param product_id [String] A Voucherify product ID or product source ID. + # @param [Hash] opts the optional parameters + # @option opts [ProductsSkusCreateRequestBody] :products_skus_create_request_body Specify the SKU parameters to be created. + # @return [ProductsSkusCreateResponseBody] + def create_sku(product_id, opts = {}) + data, _status_code, _headers = create_sku_with_http_info(product_id, opts) + data + end + + # Create SKU + # This method adds product variants to a created product. 📘 Upsert Mode If you pass an id or a source_id that already exists in the sku database, Voucherify will return a related sku object with updated fields. + # @param product_id [String] A Voucherify product ID or product source ID. + # @param [Hash] opts the optional parameters + # @option opts [ProductsSkusCreateRequestBody] :products_skus_create_request_body Specify the SKU parameters to be created. + # @return [Array<(ProductsSkusCreateResponseBody, Integer, Hash)>] ProductsSkusCreateResponseBody data, response status code and response headers + private def create_sku_with_http_info(product_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.create_sku ...' + end + # verify the required parameter 'product_id' is set + if @api_client.config.client_side_validation && product_id.nil? + fail ArgumentError, "Missing the required parameter 'product_id' when calling ProductsApi.create_sku" + end + # resource path + local_var_path = '/v1/products/{productId}/skus'.sub('{' + 'productId' + '}', CGI.escape(product_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'products_skus_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ProductsSkusCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.create_sku", + :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: ProductsApi#create_sku\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Product + # This method deletes a product. + # @param product_id [String] A Voucherify product ID or source ID. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the product will be removed permanently. Going forward, the user will be able to create another product with exactly the same source_id. + # @return [nil] + def delete_product(product_id, opts = {}) + delete_product_with_http_info(product_id, opts) + nil + end + + # Delete Product + # This method deletes a product. + # @param product_id [String] A Voucherify product ID or source ID. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the product will be removed permanently. Going forward, the user will be able to create another product with exactly the same source_id. + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_product_with_http_info(product_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.delete_product ...' + end + # verify the required parameter 'product_id' is set + if @api_client.config.client_side_validation && product_id.nil? + fail ArgumentError, "Missing the required parameter 'product_id' when calling ProductsApi.delete_product" + end + # resource path + local_var_path = '/v1/products/{productId}'.sub('{' + 'productId' + '}', CGI.escape(product_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] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.delete_product", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#delete_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete SKU + # This method deletes a product SKU. + # @param product_id [String] A unique Voucherify product ID or product source ID. + # @param sku_id [String] A Voucherify SKU ID or SKU source ID. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the SKU will be removed permanently. Going forward, the user will be able to create another SKU with exactly the same source_id. + # @return [nil] + def delete_sku(product_id, sku_id, opts = {}) + delete_sku_with_http_info(product_id, sku_id, opts) + nil + end + + # Delete SKU + # This method deletes a product SKU. + # @param product_id [String] A unique Voucherify product ID or product source ID. + # @param sku_id [String] A Voucherify SKU ID or SKU source ID. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the SKU will be removed permanently. Going forward, the user will be able to create another SKU with exactly the same source_id. + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_sku_with_http_info(product_id, sku_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.delete_sku ...' + end + # verify the required parameter 'product_id' is set + if @api_client.config.client_side_validation && product_id.nil? + fail ArgumentError, "Missing the required parameter 'product_id' when calling ProductsApi.delete_sku" + end + # verify the required parameter 'sku_id' is set + if @api_client.config.client_side_validation && sku_id.nil? + fail ArgumentError, "Missing the required parameter 'sku_id' when calling ProductsApi.delete_sku" + end + # resource path + local_var_path = '/v1/products/{productId}/skus/{skuId}'.sub('{' + 'productId' + '}', CGI.escape(product_id.to_s)).sub('{' + 'skuId' + '}', CGI.escape(sku_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] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.delete_sku", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#delete_sku\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Product + # Retrieve product details. + # @param product_id [String] A Voucherify product ID or source ID. + # @param [Hash] opts the optional parameters + # @return [ProductsGetResponseBody] + def get_product(product_id, opts = {}) + data, _status_code, _headers = get_product_with_http_info(product_id, opts) + data + end + + # Get Product + # Retrieve product details. + # @param product_id [String] A Voucherify product ID or source ID. + # @param [Hash] opts the optional parameters + # @return [Array<(ProductsGetResponseBody, Integer, Hash)>] ProductsGetResponseBody data, response status code and response headers + private def get_product_with_http_info(product_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.get_product ...' + end + # verify the required parameter 'product_id' is set + if @api_client.config.client_side_validation && product_id.nil? + fail ArgumentError, "Missing the required parameter 'product_id' when calling ProductsApi.get_product" + end + # resource path + local_var_path = '/v1/products/{productId}'.sub('{' + 'productId' + '}', CGI.escape(product_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ProductsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.get_product", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#get_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get SKU + # Retrieve details of a SKU. + # @param sku_id [String] A Voucherify SKU identifier or SKU source ID. + # @param [Hash] opts the optional parameters + # @return [SkusGetResponseBody] + def get_sku(sku_id, opts = {}) + data, _status_code, _headers = get_sku_with_http_info(sku_id, opts) + data + end + + # Get SKU + # Retrieve details of a SKU. + # @param sku_id [String] A Voucherify SKU identifier or SKU source ID. + # @param [Hash] opts the optional parameters + # @return [Array<(SkusGetResponseBody, Integer, Hash)>] SkusGetResponseBody data, response status code and response headers + private def get_sku_with_http_info(sku_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.get_sku ...' + end + # verify the required parameter 'sku_id' is set + if @api_client.config.client_side_validation && sku_id.nil? + fail ArgumentError, "Missing the required parameter 'sku_id' when calling ProductsApi.get_sku" + end + # resource path + local_var_path = '/v1/skus/{skuId}'.sub('{' + 'skuId' + '}', CGI.escape(sku_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'SkusGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.get_sku", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#get_sku\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import Products using CSV + # Import products into the repository using a CSV file. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [ProductsImportCsvCreateResponseBody] + def import_products_using_csv(file, opts = {}) + data, _status_code, _headers = import_products_using_csv_with_http_info(file, opts) + data + end + + # Import Products using CSV + # Import products into the repository using a CSV file. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [Array<(ProductsImportCsvCreateResponseBody, Integer, Hash)>] ProductsImportCsvCreateResponseBody data, response status code and response headers + private def import_products_using_csv_with_http_info(file, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.import_products_using_csv ...' + end + # verify the required parameter 'file' is set + if @api_client.config.client_side_validation && file.nil? + fail ArgumentError, "Missing the required parameter 'file' when calling ProductsApi.import_products_using_csv" + end + # resource path + local_var_path = '/v1/products/importCSV' + + # query parameters + query_params = opts[:query_params] || {} + + # 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(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['file'] = file + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ProductsImportCsvCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.import_products_using_csv", + :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: ProductsApi#import_products_using_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import SKUs using CSV + # Import SKUs into the repository using a CSV file. The CSV file has to include headers in the first line. All properties which cannot be mapped to standard SKU fields will be added to the metadata object. You can find an example template [here](https://s3.amazonaws.com/helpscout.net/docs/assets/5902f1c12c7d3a057f88a36d/attachments/627b98d08c9b585083488a4c/Import_SKUS_template.csv). This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [SkusImportCsvCreateResponseBody] + def import_skus_using_csv(file, opts = {}) + data, _status_code, _headers = import_skus_using_csv_with_http_info(file, opts) + data + end + + # Import SKUs using CSV + # Import SKUs into the repository using a CSV file. The CSV file has to include headers in the first line. All properties which cannot be mapped to standard SKU fields will be added to the metadata object. You can find an example template [here](https://s3.amazonaws.com/helpscout.net/docs/assets/5902f1c12c7d3a057f88a36d/attachments/627b98d08c9b585083488a4c/Import_SKUS_template.csv). This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [Array<(SkusImportCsvCreateResponseBody, Integer, Hash)>] SkusImportCsvCreateResponseBody data, response status code and response headers + private def import_skus_using_csv_with_http_info(file, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.import_skus_using_csv ...' + end + # verify the required parameter 'file' is set + if @api_client.config.client_side_validation && file.nil? + fail ArgumentError, "Missing the required parameter 'file' when calling ProductsApi.import_skus_using_csv" + end + # resource path + local_var_path = '/v1/skus/importCSV' + + # query parameters + query_params = opts[:query_params] || {} + + # 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(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['file'] = file + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'SkusImportCsvCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.import_skus_using_csv", + :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: ProductsApi#import_skus_using_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Products + # Retrieve a list of products. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :start_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [ProductsListResponseBody] + def list_products(opts = {}) + data, _status_code, _headers = list_products_with_http_info(opts) + data + end + + # List Products + # Retrieve a list of products. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :start_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [Array<(ProductsListResponseBody, Integer, Hash)>] ProductsListResponseBody data, response status code and response headers + private def list_products_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.list_products ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductsApi.list_products, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductsApi.list_products, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ProductsApi.list_products, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/products' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil? + query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ProductsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.list_products", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#list_products\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List SKUs in Product + # Retrieve all SKUs for a given product. + # @param product_id [String] A Voucherify product ID or product source ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :start_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [ProductsSkusListResponseBody] + def list_skus_in_product(product_id, opts = {}) + data, _status_code, _headers = list_skus_in_product_with_http_info(product_id, opts) + data + end + + # List SKUs in Product + # Retrieve all SKUs for a given product. + # @param product_id [String] A Voucherify product ID or product source ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrder] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :start_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [Array<(ProductsSkusListResponseBody, Integer, Hash)>] ProductsSkusListResponseBody data, response status code and response headers + private def list_skus_in_product_with_http_info(product_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.list_skus_in_product ...' + end + # verify the required parameter 'product_id' is set + if @api_client.config.client_side_validation && product_id.nil? + fail ArgumentError, "Missing the required parameter 'product_id' when calling ProductsApi.list_skus_in_product" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductsApi.list_skus_in_product, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ProductsApi.list_skus_in_product, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ProductsApi.list_skus_in_product, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/products/{productId}/skus'.sub('{' + 'productId' + '}', CGI.escape(product_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil? + query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ProductsSkusListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.list_skus_in_product", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#list_skus_in_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Product + # Updates the specified product by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. + # @param product_id [String] A Voucherify product ID or source ID. + # @param [Hash] opts the optional parameters + # @option opts [ProductsUpdateRequestBody] :products_update_request_body Specify the parameters of the product that are to be updated. + # @return [ProductsUpdateResponseBody] + def update_product(product_id, opts = {}) + data, _status_code, _headers = update_product_with_http_info(product_id, opts) + data + end + + # Update Product + # Updates the specified product by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. + # @param product_id [String] A Voucherify product ID or source ID. + # @param [Hash] opts the optional parameters + # @option opts [ProductsUpdateRequestBody] :products_update_request_body Specify the parameters of the product that are to be updated. + # @return [Array<(ProductsUpdateResponseBody, Integer, Hash)>] ProductsUpdateResponseBody data, response status code and response headers + private def update_product_with_http_info(product_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.update_product ...' + end + # verify the required parameter 'product_id' is set + if @api_client.config.client_side_validation && product_id.nil? + fail ArgumentError, "Missing the required parameter 'product_id' when calling ProductsApi.update_product" + end + # resource path + local_var_path = '/v1/products/{productId}'.sub('{' + 'productId' + '}', CGI.escape(product_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'products_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ProductsUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.update_product", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#update_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Products in bulk + # Update several products in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested product object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [Array] :products_update_in_bulk_request_body Create an array of product objects, each with the parameters which you want to update. + # @return [ProductsUpdateInBulkResponseBody] + def update_products_in_bulk(opts = {}) + data, _status_code, _headers = update_products_in_bulk_with_http_info(opts) + data + end + + # Update Products in bulk + # Update several products in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested product object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [Array] :products_update_in_bulk_request_body Create an array of product objects, each with the parameters which you want to update. + # @return [Array<(ProductsUpdateInBulkResponseBody, Integer, Hash)>] ProductsUpdateInBulkResponseBody data, response status code and response headers + private def update_products_in_bulk_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.update_products_in_bulk ...' + end + # resource path + local_var_path = '/v1/products/bulk/async' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'products_update_in_bulk_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ProductsUpdateInBulkResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.update_products_in_bulk", + :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: ProductsApi#update_products_in_bulk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Products' Metadata in bulk + # Update several product metadata properties in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested product object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [ProductsMetadataUpdateInBulkRequestBody] :products_metadata_update_in_bulk_request_body Specify the list of product source IDs and the metadata key value pairs to be udpated for these products. + # @return [ProductsMetadataUpdateInBulkResponseBody] + def update_products_metadata_in_bulk(opts = {}) + data, _status_code, _headers = update_products_metadata_in_bulk_with_http_info(opts) + data + end + + # Update Products' Metadata in bulk + # Update several product metadata properties in one asynchronous operation. In one request, it is possible to update a maximum of **100** records. In the response body, you get a unique async action identifier. If a requested product object is not found, then an **upsert** occurs. This is reflected in the Get Async Action endpoint as follows: This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param [Hash] opts the optional parameters + # @option opts [ProductsMetadataUpdateInBulkRequestBody] :products_metadata_update_in_bulk_request_body Specify the list of product source IDs and the metadata key value pairs to be udpated for these products. + # @return [Array<(ProductsMetadataUpdateInBulkResponseBody, Integer, Hash)>] ProductsMetadataUpdateInBulkResponseBody data, response status code and response headers + private def update_products_metadata_in_bulk_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.update_products_metadata_in_bulk ...' + end + # resource path + local_var_path = '/v1/products/metadata/async' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'products_metadata_update_in_bulk_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ProductsMetadataUpdateInBulkResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.update_products_metadata_in_bulk", + :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: ProductsApi#update_products_metadata_in_bulk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update SKU + # Updates the specified SKU by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. Fields other than the ones listed in the request body schema wont be modified. Even if provided, they will be silently skipped. + # @param product_id [String] A unique Voucherify product ID or product source ID. + # @param sku_id [String] A Voucherify SKU ID or SKU source ID. + # @param [Hash] opts the optional parameters + # @option opts [ProductsSkusUpdateRequestBody] :products_skus_update_request_body Specify the parameters to be updated. + # @return [ProductsSkusUpdateResponseBody] + def update_sku(product_id, sku_id, opts = {}) + data, _status_code, _headers = update_sku_with_http_info(product_id, sku_id, opts) + data + end + + # Update SKU + # Updates the specified SKU by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. Fields other than the ones listed in the request body schema wont be modified. Even if provided, they will be silently skipped. + # @param product_id [String] A unique Voucherify product ID or product source ID. + # @param sku_id [String] A Voucherify SKU ID or SKU source ID. + # @param [Hash] opts the optional parameters + # @option opts [ProductsSkusUpdateRequestBody] :products_skus_update_request_body Specify the parameters to be updated. + # @return [Array<(ProductsSkusUpdateResponseBody, Integer, Hash)>] ProductsSkusUpdateResponseBody data, response status code and response headers + private def update_sku_with_http_info(product_id, sku_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ProductsApi.update_sku ...' + end + # verify the required parameter 'product_id' is set + if @api_client.config.client_side_validation && product_id.nil? + fail ArgumentError, "Missing the required parameter 'product_id' when calling ProductsApi.update_sku" + end + # verify the required parameter 'sku_id' is set + if @api_client.config.client_side_validation && sku_id.nil? + fail ArgumentError, "Missing the required parameter 'sku_id' when calling ProductsApi.update_sku" + end + # resource path + local_var_path = '/v1/products/{productId}/skus/{skuId}'.sub('{' + 'productId' + '}', CGI.escape(product_id.to_s)).sub('{' + 'skuId' + '}', CGI.escape(sku_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'products_skus_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ProductsSkusUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ProductsApi.update_sku", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ProductsApi#update_sku\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/promotions_api.rb b/lib/VoucherifySdk/api/promotions_api.rb new file mode 100644 index 00000000..cde2aaa6 --- /dev/null +++ b/lib/VoucherifySdk/api/promotions_api.rb @@ -0,0 +1,764 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class PromotionsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Promotion Stack + # This method creates one promotion stack. The sequence of promotion tier IDs will determine the promotion stacking order. + # @param campaign_id [String] Unique campaign ID. + # @param [Hash] opts the optional parameters + # @option opts [PromotionsStacksCreateRequestBody] :promotions_stacks_create_request_body Specify the order of promotion tiers for the promotion stack. + # @return [PromotionsStacksCreateResponseBody] + def create_promotion_stack(campaign_id, opts = {}) + data, _status_code, _headers = create_promotion_stack_with_http_info(campaign_id, opts) + data + end + + # Create Promotion Stack + # This method creates one promotion stack. The sequence of promotion tier IDs will determine the promotion stacking order. + # @param campaign_id [String] Unique campaign ID. + # @param [Hash] opts the optional parameters + # @option opts [PromotionsStacksCreateRequestBody] :promotions_stacks_create_request_body Specify the order of promotion tiers for the promotion stack. + # @return [Array<(PromotionsStacksCreateResponseBody, Integer, Hash)>] PromotionsStacksCreateResponseBody data, response status code and response headers + private def create_promotion_stack_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.create_promotion_stack ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling PromotionsApi.create_promotion_stack" + end + # resource path + local_var_path = '/v1/promotions/{campaignId}/stacks'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'promotions_stacks_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsStacksCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.create_promotion_stack", + :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: PromotionsApi#create_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Promotion Stack + # This method deletes a promotion stack. + # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. + # @param stack_id [String] Promotion stack ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_promotion_stack(campaign_id, stack_id, opts = {}) + delete_promotion_stack_with_http_info(campaign_id, stack_id, opts) + nil + end + + # Delete Promotion Stack + # This method deletes a promotion stack. + # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. + # @param stack_id [String] Promotion stack ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_promotion_stack_with_http_info(campaign_id, stack_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.delete_promotion_stack ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling PromotionsApi.delete_promotion_stack" + end + # verify the required parameter 'stack_id' is set + if @api_client.config.client_side_validation && stack_id.nil? + fail ArgumentError, "Missing the required parameter 'stack_id' when calling PromotionsApi.delete_promotion_stack" + end + # resource path + local_var_path = '/v1/promotions/{campaignId}/stacks/{stackId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'stackId' + '}', CGI.escape(stack_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.delete_promotion_stack", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#delete_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Promotion Tier + # This method deletes a promotion tier. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_promotion_tier(promotion_tier_id, opts = {}) + delete_promotion_tier_with_http_info(promotion_tier_id, opts) + nil + end + + # Delete Promotion Tier + # This method deletes a promotion tier. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_promotion_tier_with_http_info(promotion_tier_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.delete_promotion_tier ...' + end + # verify the required parameter 'promotion_tier_id' is set + if @api_client.config.client_side_validation && promotion_tier_id.nil? + fail ArgumentError, "Missing the required parameter 'promotion_tier_id' when calling PromotionsApi.delete_promotion_tier" + end + # resource path + local_var_path = '/v1/promotions/tiers/{promotionTierId}'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.delete_promotion_tier", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#delete_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Disable Promotion Tier + # This method disables a promotion tier, i.e. makes the active parameter false. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [PromotionsTiersDisableResponseBody] + def disable_promotion_tier(promotion_tier_id, opts = {}) + data, _status_code, _headers = disable_promotion_tier_with_http_info(promotion_tier_id, opts) + data + end + + # Disable Promotion Tier + # This method disables a promotion tier, i.e. makes the active parameter false. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [Array<(PromotionsTiersDisableResponseBody, Integer, Hash)>] PromotionsTiersDisableResponseBody data, response status code and response headers + private def disable_promotion_tier_with_http_info(promotion_tier_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.disable_promotion_tier ...' + end + # verify the required parameter 'promotion_tier_id' is set + if @api_client.config.client_side_validation && promotion_tier_id.nil? + fail ArgumentError, "Missing the required parameter 'promotion_tier_id' when calling PromotionsApi.disable_promotion_tier" + end + # resource path + local_var_path = '/v1/promotions/tiers/{promotionTierId}/disable'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsTiersDisableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.disable_promotion_tier", + :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: PromotionsApi#disable_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Enable Promotion Tier + # This method enables a promotion tier, i.e. makes the active parameter true. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [PromotionsTiersEnableResponseBody] + def enable_promotion_tier(promotion_tier_id, opts = {}) + data, _status_code, _headers = enable_promotion_tier_with_http_info(promotion_tier_id, opts) + data + end + + # Enable Promotion Tier + # This method enables a promotion tier, i.e. makes the active parameter true. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [Array<(PromotionsTiersEnableResponseBody, Integer, Hash)>] PromotionsTiersEnableResponseBody data, response status code and response headers + private def enable_promotion_tier_with_http_info(promotion_tier_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.enable_promotion_tier ...' + end + # verify the required parameter 'promotion_tier_id' is set + if @api_client.config.client_side_validation && promotion_tier_id.nil? + fail ArgumentError, "Missing the required parameter 'promotion_tier_id' when calling PromotionsApi.enable_promotion_tier" + end + # resource path + local_var_path = '/v1/promotions/tiers/{promotionTierId}/enable'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsTiersEnableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.enable_promotion_tier", + :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: PromotionsApi#enable_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Promotion Stack + # This method returns the details of a promotion stack, including the promotion tiers grouped within the stack. + # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. + # @param stack_id [String] Promotion stack ID. + # @param [Hash] opts the optional parameters + # @return [PromotionsStacksGetResponseBody] + def get_promotion_stack(campaign_id, stack_id, opts = {}) + data, _status_code, _headers = get_promotion_stack_with_http_info(campaign_id, stack_id, opts) + data + end + + # Get Promotion Stack + # This method returns the details of a promotion stack, including the promotion tiers grouped within the stack. + # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. + # @param stack_id [String] Promotion stack ID. + # @param [Hash] opts the optional parameters + # @return [Array<(PromotionsStacksGetResponseBody, Integer, Hash)>] PromotionsStacksGetResponseBody data, response status code and response headers + private def get_promotion_stack_with_http_info(campaign_id, stack_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.get_promotion_stack ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling PromotionsApi.get_promotion_stack" + end + # verify the required parameter 'stack_id' is set + if @api_client.config.client_side_validation && stack_id.nil? + fail ArgumentError, "Missing the required parameter 'stack_id' when calling PromotionsApi.get_promotion_stack" + end + # resource path + local_var_path = '/v1/promotions/{campaignId}/stacks/{stackId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'stackId' + '}', CGI.escape(stack_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsStacksGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.get_promotion_stack", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#get_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Promotion Tier + # This method enables you to retrieve a specific promotion tier. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [PromotionsTiersGetResponseBody] + def get_promotion_tier(promotion_tier_id, opts = {}) + data, _status_code, _headers = get_promotion_tier_with_http_info(promotion_tier_id, opts) + data + end + + # Get Promotion Tier + # This method enables you to retrieve a specific promotion tier. + # @param promotion_tier_id [String] Unique promotion tier ID. + # @param [Hash] opts the optional parameters + # @return [Array<(PromotionsTiersGetResponseBody, Integer, Hash)>] PromotionsTiersGetResponseBody data, response status code and response headers + private def get_promotion_tier_with_http_info(promotion_tier_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.get_promotion_tier ...' + end + # verify the required parameter 'promotion_tier_id' is set + if @api_client.config.client_side_validation && promotion_tier_id.nil? + fail ArgumentError, "Missing the required parameter 'promotion_tier_id' when calling PromotionsApi.get_promotion_tier" + end + # resource path + local_var_path = '/v1/promotions/tiers/{promotionTierId}'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsTiersGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.get_promotion_tier", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#get_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Promotion Stacks + # This method enables you to list promotion stacks irrespective of the campaign they are associated with. You can use filters in the query parameters to specify the stacks to be returned in the response. # Advanced filters for fetching promotion stacks + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListAllPromotionStacks] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [ParameterCreatedBeforeAfter] :created_at A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z + # @option opts [ParameterUpdatedBeforeAfter] :updated_at A filter on the list based on the object updated_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [updated_at][before] 2017-09-08T13:52:18.227Z + # @return [PromotionsStacksListResponseBody] + def list_all_promotion_stacks(opts = {}) + data, _status_code, _headers = list_all_promotion_stacks_with_http_info(opts) + data + end + + # List Promotion Stacks + # This method enables you to list promotion stacks irrespective of the campaign they are associated with. You can use filters in the query parameters to specify the stacks to be returned in the response. # Advanced filters for fetching promotion stacks + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListAllPromotionStacks] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [ParameterCreatedBeforeAfter] :created_at A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z + # @option opts [ParameterUpdatedBeforeAfter] :updated_at A filter on the list based on the object updated_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [updated_at][before] 2017-09-08T13:52:18.227Z + # @return [Array<(PromotionsStacksListResponseBody, Integer, Hash)>] PromotionsStacksListResponseBody data, response status code and response headers + private def list_all_promotion_stacks_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.list_all_promotion_stacks ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling PromotionsApi.list_all_promotion_stacks, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling PromotionsApi.list_all_promotion_stacks, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling PromotionsApi.list_all_promotion_stacks, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/promotions/stacks' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'created_at'] = opts[:'created_at'] if !opts[:'created_at'].nil? + query_params[:'updated_at'] = opts[:'updated_at'] if !opts[:'updated_at'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsStacksListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.list_all_promotion_stacks", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#list_all_promotion_stacks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Promotion Stacks in Campaign + # This method enables you to list promotion stacks from a specified campaign. + # @param campaign_id [String] Unique campaign ID. + # @param [Hash] opts the optional parameters + # @return [PromotionsStacksListResponseBody] + def list_promotion_stacks_in_campaign(campaign_id, opts = {}) + data, _status_code, _headers = list_promotion_stacks_in_campaign_with_http_info(campaign_id, opts) + data + end + + # List Promotion Stacks in Campaign + # This method enables you to list promotion stacks from a specified campaign. + # @param campaign_id [String] Unique campaign ID. + # @param [Hash] opts the optional parameters + # @return [Array<(PromotionsStacksListResponseBody, Integer, Hash)>] PromotionsStacksListResponseBody data, response status code and response headers + private def list_promotion_stacks_in_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.list_promotion_stacks_in_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling PromotionsApi.list_promotion_stacks_in_campaign" + end + # resource path + local_var_path = '/v1/promotions/{campaignId}/stacks'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsStacksListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.list_promotion_stacks_in_campaign", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#list_promotion_stacks_in_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Promotion Tiers from Campaign + # This method enables you to list promotion tiers from a specified campaign. + # @param campaign_id [String] Unique campaign ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @return [PromotionsTiersListResponseBody] + def list_promotion_tiers_from_campaign(campaign_id, opts = {}) + data, _status_code, _headers = list_promotion_tiers_from_campaign_with_http_info(campaign_id, opts) + data + end + + # List Promotion Tiers from Campaign + # This method enables you to list promotion tiers from a specified campaign. + # @param campaign_id [String] Unique campaign ID assigned by Voucherify. + # @param [Hash] opts the optional parameters + # @return [Array<(PromotionsTiersListResponseBody, Integer, Hash)>] PromotionsTiersListResponseBody data, response status code and response headers + private def list_promotion_tiers_from_campaign_with_http_info(campaign_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.list_promotion_tiers_from_campaign ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling PromotionsApi.list_promotion_tiers_from_campaign" + end + # resource path + local_var_path = '/v1/promotions/{campaignId}/tiers'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsTiersListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.list_promotion_tiers_from_campaign", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#list_promotion_tiers_from_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Promotion Stack + # This methods allows for editing an existing stack. + # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. + # @param stack_id [String] Promotion stack ID. + # @param [Hash] opts the optional parameters + # @option opts [PromotionsStacksUpdateRequestBody] :promotions_stacks_update_request_body Specify the promotion stack parameters that you would like to update. + # @return [PromotionsStacksUpdateResponseBody] + def update_promotion_stack(campaign_id, stack_id, opts = {}) + data, _status_code, _headers = update_promotion_stack_with_http_info(campaign_id, stack_id, opts) + data + end + + # Update Promotion Stack + # This methods allows for editing an existing stack. + # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. + # @param stack_id [String] Promotion stack ID. + # @param [Hash] opts the optional parameters + # @option opts [PromotionsStacksUpdateRequestBody] :promotions_stacks_update_request_body Specify the promotion stack parameters that you would like to update. + # @return [Array<(PromotionsStacksUpdateResponseBody, Integer, Hash)>] PromotionsStacksUpdateResponseBody data, response status code and response headers + private def update_promotion_stack_with_http_info(campaign_id, stack_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PromotionsApi.update_promotion_stack ...' + end + # verify the required parameter 'campaign_id' is set + if @api_client.config.client_side_validation && campaign_id.nil? + fail ArgumentError, "Missing the required parameter 'campaign_id' when calling PromotionsApi.update_promotion_stack" + end + # verify the required parameter 'stack_id' is set + if @api_client.config.client_side_validation && stack_id.nil? + fail ArgumentError, "Missing the required parameter 'stack_id' when calling PromotionsApi.update_promotion_stack" + end + # resource path + local_var_path = '/v1/promotions/{campaignId}/stacks/{stackId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'stackId' + '}', CGI.escape(stack_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'promotions_stacks_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'PromotionsStacksUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PromotionsApi.update_promotion_stack", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PromotionsApi#update_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/publications_api.rb b/lib/VoucherifySdk/api/publications_api.rb new file mode 100644 index 00000000..ec9a0473 --- /dev/null +++ b/lib/VoucherifySdk/api/publications_api.rb @@ -0,0 +1,270 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class PublicationsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Publication + # This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet. 🚧 Clearly define the source of the voucher You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. 🚧 Publish multiple vouchers In case you want to publish multiple vouchers within a single publication, you need to specify the campaign name and number of vouchers you want to publish. 📘 Auto-update campaign In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :join_once Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. + # @option opts [PublicationsCreateRequestBody] :publications_create_request_body Specify the publication parameters. + # @return [PublicationsCreateResponseBody] + def create_publication(opts = {}) + data, _status_code, _headers = create_publication_with_http_info(opts) + data + end + + # Create Publication + # This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet. 🚧 Clearly define the source of the voucher You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. 🚧 Publish multiple vouchers In case you want to publish multiple vouchers within a single publication, you need to specify the campaign name and number of vouchers you want to publish. 📘 Auto-update campaign In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :join_once Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. + # @option opts [PublicationsCreateRequestBody] :publications_create_request_body Specify the publication parameters. + # @return [Array<(PublicationsCreateResponseBody, Integer, Hash)>] PublicationsCreateResponseBody data, response status code and response headers + private def create_publication_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PublicationsApi.create_publication ...' + end + # resource path + local_var_path = '/v1/publications' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'join_once'] = opts[:'join_once'] if !opts[:'join_once'].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[:'publications_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'PublicationsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PublicationsApi.create_publication", + :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: PublicationsApi#create_publication\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Create Publication + # This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet. ❗️ Limited access Access to this endpoint is limited. This endpoint is designed for specific integrations and the API keys need to be configured to access this endpoint. Navigate to the **Dashboard** → **Project Settings** → **General** → **Integration Keys** to set up a pair of API keys and use them to send the request. 🚧 Clearly define the source of the voucher You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. 🚧 Publish multiple vouchers This endpoint does not support the publishing of multiple vouchers from a single campaign. In case you want to publish multiple vouchers within a single publication, you need to use a dedicated endpoint. 📘 Auto-update campaign In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. # Example Request ❗️ Required Query param voucher OR campaign MUST be filled out. If you provide both, campaign param will be skipped. + # @param customer [Customer] Contains information about the customer to whom the publication was directed. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :join_once Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. + # @option opts [String] :voucher Code of voucher being published. + # @option opts [CreatePublicationCampaign] :campaign Create publication with campaign. + # @option opts [String] :source_id The merchant’s publication ID if it is different from the Voucherify publication ID. Its an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If source_id is provided only 1 voucher can be published per request. + # @option opts [Object] :metadata The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + # @return [PublicationsCreateResponseBody] + def create_publication1(customer, opts = {}) + data, _status_code, _headers = create_publication1_with_http_info(customer, opts) + data + end + + # Create Publication + # This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication. A voucher is suitable for publication when its active and hasnt been published yet. ❗️ Limited access Access to this endpoint is limited. This endpoint is designed for specific integrations and the API keys need to be configured to access this endpoint. Navigate to the **Dashboard** &rarr; **Project Settings** &rarr; **General** &rarr; **Integration Keys** to set up a pair of API keys and use them to send the request. 🚧 Clearly define the source of the voucher You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code. 🚧 Publish multiple vouchers This endpoint does not support the publishing of multiple vouchers from a single campaign. In case you want to publish multiple vouchers within a single publication, you need to use a dedicated endpoint. 📘 Auto-update campaign In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an **auto-update** campaign. # Example Request ❗️ Required Query param voucher OR campaign MUST be filled out. If you provide both, campaign param will be skipped. + # @param customer [Customer] Contains information about the customer to whom the publication was directed. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :join_once Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer. + # @option opts [String] :voucher Code of voucher being published. + # @option opts [CreatePublicationCampaign] :campaign Create publication with campaign. + # @option opts [String] :source_id The merchant’s publication ID if it is different from the Voucherify publication ID. Its an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If source_id is provided only 1 voucher can be published per request. + # @option opts [Object] :metadata The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + # @return [Array<(PublicationsCreateResponseBody, Integer, Hash)>] PublicationsCreateResponseBody data, response status code and response headers + private def create_publication1_with_http_info(customer, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PublicationsApi.create_publication1 ...' + end + # verify the required parameter 'customer' is set + if @api_client.config.client_side_validation && customer.nil? + fail ArgumentError, "Missing the required parameter 'customer' when calling PublicationsApi.create_publication1" + end + # resource path + local_var_path = '/v1/publications/create' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'customer'] = customer + query_params[:'join_once'] = opts[:'join_once'] if !opts[:'join_once'].nil? + query_params[:'voucher'] = opts[:'voucher'] if !opts[:'voucher'].nil? + query_params[:'campaign'] = opts[:'campaign'] if !opts[:'campaign'].nil? + query_params[:'source_id'] = opts[:'source_id'] if !opts[:'source_id'].nil? + query_params[:'metadata'] = opts[:'metadata'] if !opts[:'metadata'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PublicationsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PublicationsApi.create_publication1", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PublicationsApi#create_publication1\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Publications + # Retrieve a list of publications. To return a **particular** publication, you can use the source_id query parameter and provide the source_id of the publication you are looking for specifically. # Pagination 🚧 Important! If you want to scroll through a huge set of records, it is recommended to use the Exports API. This API will return an error page_over_limit if you reach a page above 1000. # Filter Query The filters query parameter allows for joining multiple parameters with logical operators. The syntax looks as follows: ## Operators: ## Examples + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListPublications] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [String] :campaign Filters by a given campaign name. + # @option opts [String] :customer Filters by a unique customer ID. + # @option opts [String] :voucher Filters by a given voucher code. + # @option opts [ParameterResultListPublications] :result Filters by a publication result. + # @option opts [ParameterVoucherTypeListPublications] :voucher_type Filters by a voucher type. + # @option opts [Boolean] :is_referral_code This filter works only for the true option. If set to true, the query returns only publications of codes from referral campaigns. + # @option opts [String] :filters Allows for combining the filters mentioned in the endpoint description. + # @option opts [String] :source_id Using this endpoint with a particular publication source_id, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular source_id. + # @return [PublicationsListResponseBody] + def list_publications(opts = {}) + data, _status_code, _headers = list_publications_with_http_info(opts) + data + end + + # List Publications + # Retrieve a list of publications. To return a **particular** publication, you can use the source_id query parameter and provide the source_id of the publication you are looking for specifically. # Pagination 🚧 Important! If you want to scroll through a huge set of records, it is recommended to use the Exports API. This API will return an error page_over_limit if you reach a page above 1000. # Filter Query The filters query parameter allows for joining multiple parameters with logical operators. The syntax looks as follows: ## Operators: ## Examples + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListPublications] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [String] :campaign Filters by a given campaign name. + # @option opts [String] :customer Filters by a unique customer ID. + # @option opts [String] :voucher Filters by a given voucher code. + # @option opts [ParameterResultListPublications] :result Filters by a publication result. + # @option opts [ParameterVoucherTypeListPublications] :voucher_type Filters by a voucher type. + # @option opts [Boolean] :is_referral_code This filter works only for the true option. If set to true, the query returns only publications of codes from referral campaigns. + # @option opts [String] :filters Allows for combining the filters mentioned in the endpoint description. + # @option opts [String] :source_id Using this endpoint with a particular publication source_id, which was sent with the original request to create a publication, returns in the response, exactly the same code published initially because the code was assigned to the given publication. As a result, you can use this endpoint as a reference and return a code that was assigned in a publication by using a particular source_id. + # @return [Array<(PublicationsListResponseBody, Integer, Hash)>] PublicationsListResponseBody data, response status code and response headers + private def list_publications_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PublicationsApi.list_publications ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling PublicationsApi.list_publications, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling PublicationsApi.list_publications, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling PublicationsApi.list_publications, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/publications' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'campaign'] = opts[:'campaign'] if !opts[:'campaign'].nil? + query_params[:'customer'] = opts[:'customer'] if !opts[:'customer'].nil? + query_params[:'voucher'] = opts[:'voucher'] if !opts[:'voucher'].nil? + query_params[:'result'] = opts[:'result'] if !opts[:'result'].nil? + query_params[:'voucher_type'] = opts[:'voucher_type'] if !opts[:'voucher_type'].nil? + query_params[:'is_referral_code'] = opts[:'is_referral_code'] if !opts[:'is_referral_code'].nil? + query_params[:'filters'] = opts[:'filters'] if !opts[:'filters'].nil? + query_params[:'source_id'] = opts[:'source_id'] if !opts[:'source_id'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'PublicationsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"PublicationsApi.list_publications", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PublicationsApi#list_publications\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/qualifications_api.rb b/lib/VoucherifySdk/api/qualifications_api.rb new file mode 100644 index 00000000..15cbaaa6 --- /dev/null +++ b/lib/VoucherifySdk/api/qualifications_api.rb @@ -0,0 +1,86 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class QualificationsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Check Eligibility + # 🚧 The Qualifications endpoint in the basic mode ignores the rules checking: - Limit of total redeemed discount amount per campaign - Limit of total redemptions count per campaign - Redemptions per customer - Redemptions per customer in a campaign Generate a list of redeemables that are applicable in the context of the customer and order. The new qualifications method is an improved version of Campaign Qualifications, Voucher Qualifications, and Promotions Validation API requests. The new qualification method introduces the following improvements: - Qualification results are returned faster - No limit on the number of returned redeemables - Introduces new qualification scenarios, not available in the previous version 👍 Scenario Guide Read our dedicated guide to learn about some use cases this endpoint can cover here. # Paging The Voucherify Qualifications API request will return to you all of the redeemables available for the customer in batches of up to 50 redeemables. To get the next batch of redeemables, you need to use the starting_after cursor. To process of paging the redeemables works in the following manner: - You send the first API request for Qualifications without the starting_after parameter. - The response will contain a parameter named has_more. If the parameters value is set to true, then more redeemables are available. - Get the value of the created_at parameter of the last returned redeemable. The value of this parameter will be used as a cursor to retrieve the next page of redeemables. - Send another API request for Qualification with the starting_after parameter set to the value taken from the created_at parameter from the last returned redeemable. - Voucherify will return the next page of redeemables. - If the has_more parameter is set to true, apply steps 3-5 to get the next page of redeemables. + # @param [Hash] opts the optional parameters + # @option opts [QualificationsCheckEligibilityRequestBody] :qualifications_check_eligibility_request_body Define order and customer context. + # @return [QualificationsCheckEligibilityResponseBody] + def check_eligibility(opts = {}) + data, _status_code, _headers = check_eligibility_with_http_info(opts) + data + end + + # Check Eligibility + # 🚧 The Qualifications endpoint in the basic mode ignores the rules checking: - Limit of total redeemed discount amount per campaign - Limit of total redemptions count per campaign - Redemptions per customer - Redemptions per customer in a campaign Generate a list of redeemables that are applicable in the context of the customer and order. The new qualifications method is an improved version of Campaign Qualifications, Voucher Qualifications, and Promotions Validation API requests. The new qualification method introduces the following improvements: - Qualification results are returned faster - No limit on the number of returned redeemables - Introduces new qualification scenarios, not available in the previous version 👍 Scenario Guide Read our dedicated guide to learn about some use cases this endpoint can cover here. # Paging The Voucherify Qualifications API request will return to you all of the redeemables available for the customer in batches of up to 50 redeemables. To get the next batch of redeemables, you need to use the starting_after cursor. To process of paging the redeemables works in the following manner: - You send the first API request for Qualifications without the starting_after parameter. - The response will contain a parameter named has_more. If the parameters value is set to true, then more redeemables are available. - Get the value of the created_at parameter of the last returned redeemable. The value of this parameter will be used as a cursor to retrieve the next page of redeemables. - Send another API request for Qualification with the starting_after parameter set to the value taken from the created_at parameter from the last returned redeemable. - Voucherify will return the next page of redeemables. - If the has_more parameter is set to true, apply steps 3-5 to get the next page of redeemables. + # @param [Hash] opts the optional parameters + # @option opts [QualificationsCheckEligibilityRequestBody] :qualifications_check_eligibility_request_body Define order and customer context. + # @return [Array<(QualificationsCheckEligibilityResponseBody, Integer, Hash)>] QualificationsCheckEligibilityResponseBody data, response status code and response headers + private def check_eligibility_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: QualificationsApi.check_eligibility ...' + end + # resource path + local_var_path = '/v1/qualifications' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'qualifications_check_eligibility_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'QualificationsCheckEligibilityResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"QualificationsApi.check_eligibility", + :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: QualificationsApi#check_eligibility\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/redemptions_api.rb b/lib/VoucherifySdk/api/redemptions_api.rb new file mode 100644 index 00000000..26616d7d --- /dev/null +++ b/lib/VoucherifySdk/api/redemptions_api.rb @@ -0,0 +1,457 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class RedemptionsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Get Redemption + # Return a redemption or redemption rollback object. This object can either be a successfull or failed redemption or redemption rollback. + # @param redemption_id [String] ID of previously created redemption. + # @param [Hash] opts the optional parameters + # @return [RedemptionsGetResponseBody] + def get_redemption(redemption_id, opts = {}) + data, _status_code, _headers = get_redemption_with_http_info(redemption_id, opts) + data + end + + # Get Redemption + # Return a redemption or redemption rollback object. This object can either be a successfull or failed redemption or redemption rollback. + # @param redemption_id [String] ID of previously created redemption. + # @param [Hash] opts the optional parameters + # @return [Array<(RedemptionsGetResponseBody, Integer, Hash)>] RedemptionsGetResponseBody data, response status code and response headers + private def get_redemption_with_http_info(redemption_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RedemptionsApi.get_redemption ...' + end + # verify the required parameter 'redemption_id' is set + if @api_client.config.client_side_validation && redemption_id.nil? + fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.get_redemption" + end + # resource path + local_var_path = '/v1/redemptions/{redemptionId}'.sub('{' + 'redemptionId' + '}', CGI.escape(redemption_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'RedemptionsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RedemptionsApi.get_redemption", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RedemptionsApi#get_redemption\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Voucher's Redemptions + # Retrieve the number of times a voucher was redeemed and each of the redemption details. + # @param code [String] A **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @return [VouchersRedemptionGetResponseBody] + def get_voucher_redemptions(code, opts = {}) + data, _status_code, _headers = get_voucher_redemptions_with_http_info(code, opts) + data + end + + # Get Voucher's Redemptions + # Retrieve the number of times a voucher was redeemed and each of the redemption details. + # @param code [String] A **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @return [Array<(VouchersRedemptionGetResponseBody, Integer, Hash)>] VouchersRedemptionGetResponseBody data, response status code and response headers + private def get_voucher_redemptions_with_http_info(code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RedemptionsApi.get_voucher_redemptions ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling RedemptionsApi.get_voucher_redemptions" + end + # resource path + local_var_path = '/v1/vouchers/{code}/redemption'.sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'VouchersRedemptionGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RedemptionsApi.get_voucher_redemptions", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RedemptionsApi#get_voucher_redemptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Redemptions + # Returns a list of redemptions previously created. The redemptions are returned in a sorted order, with the most recent redemptions appearing first. The response returns a list of redemptions of all vouchers. # Filtering results The result can be narrowed according to specified (or default) filters, for example, you can sort redemptions by date: https://api.voucherify.io/v1/redemptions?limit 3&[created_at][before] 2017-09-08T13:52:18.227Z. A filter based on the object created_at field narrows down the results and lists redemptions done before or after a particular date time. You can use the following options: [created_at][after], [created_at][before]. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z. # Failed Redemptions A redemption may fail for various reasons. You can figure out an exact reason from the failure_code: - resource_not_found - voucher with given code does not exist - voucher_not_active - voucher is not active yet (before start date) - voucher_expired - voucher has already expired (after expiration date) - voucher_disabled - voucher has been disabled (active: false) - quantity_exceeded - vouchers redemptions limit has been exceeded - gift_amount_exceeded - gift amount has been exceeded - customer_rules_violated - customer did not match the segment - order_rules_violated - order did not match validation rules - invalid_order - order was specified incorrectly - invalid_amount - order amount was specified incorrectly - missing_amount - order amount was not specified - missing_order_items - order items were not specified - missing_customer - customer was not specified + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [String] :result A filter on the list based on the redemption result. Available options are: SUCCESS, FAILURE. You can provide multiple values by repeating the param. + # @option opts [String] :campaign A filter by the campaign **name** that the redemption resources originate from. + # @option opts [String] :customer Return redemptions performed by the customer with given id or source_id. + # @option opts [ParameterOrderListRedemptions] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [ParameterCreatedBeforeAfter] :created_at A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z + # @option opts [ParameterFiltersListRedemptions] :filters Filters for listing responses. + # @return [RedemptionsListResponseBody] + def list_redemptions(opts = {}) + data, _status_code, _headers = list_redemptions_with_http_info(opts) + data + end + + # List Redemptions + # Returns a list of redemptions previously created. The redemptions are returned in a sorted order, with the most recent redemptions appearing first. The response returns a list of redemptions of all vouchers. # Filtering results The result can be narrowed according to specified (or default) filters, for example, you can sort redemptions by date: https://api.voucherify.io/v1/redemptions?limit 3&[created_at][before] 2017-09-08T13:52:18.227Z. A filter based on the object created_at field narrows down the results and lists redemptions done before or after a particular date time. You can use the following options: [created_at][after], [created_at][before]. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z. # Failed Redemptions A redemption may fail for various reasons. You can figure out an exact reason from the failure_code: - resource_not_found - voucher with given code does not exist - voucher_not_active - voucher is not active yet (before start date) - voucher_expired - voucher has already expired (after expiration date) - voucher_disabled - voucher has been disabled (active: false) - quantity_exceeded - vouchers redemptions limit has been exceeded - gift_amount_exceeded - gift amount has been exceeded - customer_rules_violated - customer did not match the segment - order_rules_violated - order did not match validation rules - invalid_order - order was specified incorrectly - invalid_amount - order amount was specified incorrectly - missing_amount - order amount was not specified - missing_order_items - order items were not specified - missing_customer - customer was not specified + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [String] :result A filter on the list based on the redemption result. Available options are: SUCCESS, FAILURE. You can provide multiple values by repeating the param. + # @option opts [String] :campaign A filter by the campaign **name** that the redemption resources originate from. + # @option opts [String] :customer Return redemptions performed by the customer with given id or source_id. + # @option opts [ParameterOrderListRedemptions] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [ParameterCreatedBeforeAfter] :created_at A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z + # @option opts [ParameterFiltersListRedemptions] :filters Filters for listing responses. + # @return [Array<(RedemptionsListResponseBody, Integer, Hash)>] RedemptionsListResponseBody data, response status code and response headers + private def list_redemptions_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RedemptionsApi.list_redemptions ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RedemptionsApi.list_redemptions, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RedemptionsApi.list_redemptions, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling RedemptionsApi.list_redemptions, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/redemptions' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'result'] = opts[:'result'] if !opts[:'result'].nil? + query_params[:'campaign'] = opts[:'campaign'] if !opts[:'campaign'].nil? + query_params[:'customer'] = opts[:'customer'] if !opts[:'customer'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'created_at'] = opts[:'created_at'] if !opts[:'created_at'].nil? + query_params[:'filters'] = opts[:'filters'] if !opts[:'filters'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'RedemptionsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RedemptionsApi.list_redemptions", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RedemptionsApi#list_redemptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Redeem Stackable Discounts + # # How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: 📘 Rollbacks You cant roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your rollback request. 📘 Also available on client-side This method is also accessible through public keys which you can use in client-side​ apps: mobile and web browser apps. Go to the dedicated endpoint to learn more. - Use X-Client-Application-Id as the application ID header. - Use X-Client-Token as the appliction secret key header. - Use client-side base URL. - Use an origin header for your custom domain. + # @param [Hash] opts the optional parameters + # @option opts [RedemptionsRedeemRequestBody] :redemptions_redeem_request_body + # @return [RedemptionsRedeemResponseBody] + def redeem_stacked_discounts(opts = {}) + data, _status_code, _headers = redeem_stacked_discounts_with_http_info(opts) + data + end + + # Redeem Stackable Discounts + # # How API returns calculated discounts and order amounts in the response In the table below, you can see the logic the API follows to calculate discounts and amounts: 📘 Rollbacks You cant roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your rollback request. 📘 Also available on client-side This method is also accessible through public keys which you can use in client-side​ apps: mobile and web browser apps. Go to the dedicated endpoint to learn more. - Use X-Client-Application-Id as the application ID header. - Use X-Client-Token as the appliction secret key header. - Use client-side base URL. - Use an origin header for your custom domain. + # @param [Hash] opts the optional parameters + # @option opts [RedemptionsRedeemRequestBody] :redemptions_redeem_request_body + # @return [Array<(RedemptionsRedeemResponseBody, Integer, Hash)>] RedemptionsRedeemResponseBody data, response status code and response headers + private def redeem_stacked_discounts_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RedemptionsApi.redeem_stacked_discounts ...' + end + # resource path + local_var_path = '/v1/redemptions' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'redemptions_redeem_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'RedemptionsRedeemResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RedemptionsApi.redeem_stacked_discounts", + :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: RedemptionsApi#redeem_stacked_discounts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Rollback Redemption + # Your business logic may include a case when you need to undo a redemption. You can revert a redemption by calling this API endpoint. # Effect The operation - creates a rollback entry in vouchers redemption history (redemption.redemption_entries) and - gives 1 redemption back to the pool (decreases redeemed_quantity by 1). # Returned funds In case of *gift card vouchers*, this method returns funds back according to the source redemption. In case of *loyalty card vouchers*, this method returns points back according to the source redemption. + # @param redemption_id [String] The original redemption ID to be rolled back (undone). + # @param [Hash] opts the optional parameters + # @option opts [String] :reason Reason for the rollback. + # @option opts [String] :tracking_id Customers source_id. + # @option opts [RedemptionsRollbackCreateRequestBody] :redemptions_rollback_create_request_body Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. + # @return [RedemptionsRollbackCreateResponseBody] + def rollback_redemption(redemption_id, opts = {}) + data, _status_code, _headers = rollback_redemption_with_http_info(redemption_id, opts) + data + end + + # Rollback Redemption + # Your business logic may include a case when you need to undo a redemption. You can revert a redemption by calling this API endpoint. # Effect The operation - creates a rollback entry in vouchers redemption history (redemption.redemption_entries) and - gives 1 redemption back to the pool (decreases redeemed_quantity by 1). # Returned funds In case of *gift card vouchers*, this method returns funds back according to the source redemption. In case of *loyalty card vouchers*, this method returns points back according to the source redemption. + # @param redemption_id [String] The original redemption ID to be rolled back (undone). + # @param [Hash] opts the optional parameters + # @option opts [String] :reason Reason for the rollback. + # @option opts [String] :tracking_id Customers source_id. + # @option opts [RedemptionsRollbackCreateRequestBody] :redemptions_rollback_create_request_body Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. + # @return [Array<(RedemptionsRollbackCreateResponseBody, Integer, Hash)>] RedemptionsRollbackCreateResponseBody data, response status code and response headers + private def rollback_redemption_with_http_info(redemption_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RedemptionsApi.rollback_redemption ...' + end + # verify the required parameter 'redemption_id' is set + if @api_client.config.client_side_validation && redemption_id.nil? + fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.rollback_redemption" + end + # resource path + local_var_path = '/v1/redemptions/{redemptionId}/rollback'.sub('{' + 'redemptionId' + '}', CGI.escape(redemption_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'reason'] = opts[:'reason'] if !opts[:'reason'].nil? + query_params[:'tracking_id'] = opts[:'tracking_id'] if !opts[:'tracking_id'].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[:'redemptions_rollback_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'RedemptionsRollbackCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RedemptionsApi.rollback_redemption", + :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: RedemptionsApi#rollback_redemption\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Rollback Stackable Redemptions + # Rollback a stackable redemption. When you rollback a stacked redemption, all child redemptions will be rolled back. Provide the parent redemption ID as the path parameter. + # @param parent_redemption_id [String] Unique identifier of a parent redemption, e.g. r_JQfm73zWSJFQxs3bGxweYjgm. + # @param [Hash] opts the optional parameters + # @option opts [String] :reason Reason for the rollback. + # @option opts [String] :tracking_id Customers source_id. + # @option opts [RedemptionsRollbacksCreateRequestBody] :redemptions_rollbacks_create_request_body Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. + # @return [RedemptionsRollbacksCreateResponseBody] + def rollback_stacked_redemptions(parent_redemption_id, opts = {}) + data, _status_code, _headers = rollback_stacked_redemptions_with_http_info(parent_redemption_id, opts) + data + end + + # Rollback Stackable Redemptions + # Rollback a stackable redemption. When you rollback a stacked redemption, all child redemptions will be rolled back. Provide the parent redemption ID as the path parameter. + # @param parent_redemption_id [String] Unique identifier of a parent redemption, e.g. r_JQfm73zWSJFQxs3bGxweYjgm. + # @param [Hash] opts the optional parameters + # @option opts [String] :reason Reason for the rollback. + # @option opts [String] :tracking_id Customers source_id. + # @option opts [RedemptionsRollbacksCreateRequestBody] :redemptions_rollbacks_create_request_body Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body. + # @return [Array<(RedemptionsRollbacksCreateResponseBody, Integer, Hash)>] RedemptionsRollbacksCreateResponseBody data, response status code and response headers + private def rollback_stacked_redemptions_with_http_info(parent_redemption_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RedemptionsApi.rollback_stacked_redemptions ...' + end + # verify the required parameter 'parent_redemption_id' is set + if @api_client.config.client_side_validation && parent_redemption_id.nil? + fail ArgumentError, "Missing the required parameter 'parent_redemption_id' when calling RedemptionsApi.rollback_stacked_redemptions" + end + # resource path + local_var_path = '/v1/redemptions/{parentRedemptionId}/rollbacks'.sub('{' + 'parentRedemptionId' + '}', CGI.escape(parent_redemption_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'reason'] = opts[:'reason'] if !opts[:'reason'].nil? + query_params[:'tracking_id'] = opts[:'tracking_id'] if !opts[:'tracking_id'].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[:'redemptions_rollbacks_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'RedemptionsRollbacksCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RedemptionsApi.rollback_stacked_redemptions", + :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: RedemptionsApi#rollback_stacked_redemptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/rewards_api.rb b/lib/VoucherifySdk/api/rewards_api.rb new file mode 100644 index 00000000..3e96d13a --- /dev/null +++ b/lib/VoucherifySdk/api/rewards_api.rb @@ -0,0 +1,446 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class RewardsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Reward Assignment + # Assigns a reward to a specified loyalty campaign. + # @param reward_id [String] A unique reward ID. + # @param [Hash] opts the optional parameters + # @option opts [RewardsAssignmentsCreateRequestBody] :rewards_assignments_create_request_body Provide the campaign ID of the campaign to which the reward is to be assigned and define the cost of the reward in terms of loyalty points. + # @return [RewardsAssignmentsCreateResponseBody] + def create_reward_assignment(reward_id, opts = {}) + data, _status_code, _headers = create_reward_assignment_with_http_info(reward_id, opts) + data + end + + # Create Reward Assignment + # Assigns a reward to a specified loyalty campaign. + # @param reward_id [String] A unique reward ID. + # @param [Hash] opts the optional parameters + # @option opts [RewardsAssignmentsCreateRequestBody] :rewards_assignments_create_request_body Provide the campaign ID of the campaign to which the reward is to be assigned and define the cost of the reward in terms of loyalty points. + # @return [Array<(RewardsAssignmentsCreateResponseBody, Integer, Hash)>] RewardsAssignmentsCreateResponseBody data, response status code and response headers + private def create_reward_assignment_with_http_info(reward_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RewardsApi.create_reward_assignment ...' + end + # verify the required parameter 'reward_id' is set + if @api_client.config.client_side_validation && reward_id.nil? + fail ArgumentError, "Missing the required parameter 'reward_id' when calling RewardsApi.create_reward_assignment" + end + # resource path + local_var_path = '/v1/rewards/{rewardId}/assignments'.sub('{' + 'rewardId' + '}', CGI.escape(reward_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'rewards_assignments_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'RewardsAssignmentsCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RewardsApi.create_reward_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: RewardsApi#create_reward_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Reward + # Delete a reward. + # @param reward_id [String] A unique reward ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_reward(reward_id, opts = {}) + delete_reward_with_http_info(reward_id, opts) + nil + end + + # Delete Reward + # Delete a reward. + # @param reward_id [String] A unique reward ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_reward_with_http_info(reward_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RewardsApi.delete_reward ...' + end + # verify the required parameter 'reward_id' is set + if @api_client.config.client_side_validation && reward_id.nil? + fail ArgumentError, "Missing the required parameter 'reward_id' when calling RewardsApi.delete_reward" + end + # resource path + local_var_path = '/v1/rewards/{rewardId}'.sub('{' + 'rewardId' + '}', CGI.escape(reward_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RewardsApi.delete_reward", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RewardsApi#delete_reward\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Reward Assignment + # This method deletes a reward assignment for a particular reward. + # @param reward_id [String] A unique reward ID. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_reward_assignment(reward_id, assignment_id, opts = {}) + delete_reward_assignment_with_http_info(reward_id, assignment_id, opts) + nil + end + + # Delete Reward Assignment + # This method deletes a reward assignment for a particular reward. + # @param reward_id [String] A unique reward ID. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_reward_assignment_with_http_info(reward_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RewardsApi.delete_reward_assignment ...' + end + # verify the required parameter 'reward_id' is set + if @api_client.config.client_side_validation && reward_id.nil? + fail ArgumentError, "Missing the required parameter 'reward_id' when calling RewardsApi.delete_reward_assignment" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling RewardsApi.delete_reward_assignment" + end + # resource path + local_var_path = '/v1/rewards/{rewardId}/assignments/{assignmentId}'.sub('{' + 'rewardId' + '}', CGI.escape(reward_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RewardsApi.delete_reward_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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RewardsApi#delete_reward_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Reward Assignment + # Retrieve a reward assignment. + # @param reward_id [String] A unique reward ID. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [RewardsAssignmentsGetResponseBody] + def get_reward_assignment(reward_id, assignment_id, opts = {}) + data, _status_code, _headers = get_reward_assignment_with_http_info(reward_id, assignment_id, opts) + data + end + + # Get Reward Assignment + # Retrieve a reward assignment. + # @param reward_id [String] A unique reward ID. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(RewardsAssignmentsGetResponseBody, Integer, Hash)>] RewardsAssignmentsGetResponseBody data, response status code and response headers + private def get_reward_assignment_with_http_info(reward_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RewardsApi.get_reward_assignment ...' + end + # verify the required parameter 'reward_id' is set + if @api_client.config.client_side_validation && reward_id.nil? + fail ArgumentError, "Missing the required parameter 'reward_id' when calling RewardsApi.get_reward_assignment" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling RewardsApi.get_reward_assignment" + end + # resource path + local_var_path = '/v1/rewards/{rewardId}/assignments/{assignmentId}'.sub('{' + 'rewardId' + '}', CGI.escape(reward_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'RewardsAssignmentsGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RewardsApi.get_reward_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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RewardsApi#get_reward_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Reward Assignments + # Retrieve reward assignments by the reward ID. + # @param reward_id [String] A unique reward ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [RewardsAssignmentsListResponseBody] + def list_reward_assignments(reward_id, opts = {}) + data, _status_code, _headers = list_reward_assignments_with_http_info(reward_id, opts) + data + end + + # List Reward Assignments + # Retrieve reward assignments by the reward ID. + # @param reward_id [String] A unique reward ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [Array<(RewardsAssignmentsListResponseBody, Integer, Hash)>] RewardsAssignmentsListResponseBody data, response status code and response headers + private def list_reward_assignments_with_http_info(reward_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RewardsApi.list_reward_assignments ...' + end + # verify the required parameter 'reward_id' is set + if @api_client.config.client_side_validation && reward_id.nil? + fail ArgumentError, "Missing the required parameter 'reward_id' when calling RewardsApi.list_reward_assignments" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RewardsApi.list_reward_assignments, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RewardsApi.list_reward_assignments, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling RewardsApi.list_reward_assignments, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/rewards/{rewardId}/assignments'.sub('{' + 'rewardId' + '}', CGI.escape(reward_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'RewardsAssignmentsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RewardsApi.list_reward_assignments", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RewardsApi#list_reward_assignments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Reward Assignment + # Update the number of points needed to successfully redeem the reward. + # @param reward_id [String] A unique reward ID. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @option opts [RewardsAssignmentsUpdateRequestBody] :rewards_assignments_update_request_body Define the number of points required to exchange for the reward. + # @return [RewardsAssignmentsUpdateResponseBody] + def update_reward_assignment(reward_id, assignment_id, opts = {}) + data, _status_code, _headers = update_reward_assignment_with_http_info(reward_id, assignment_id, opts) + data + end + + # Update Reward Assignment + # Update the number of points needed to successfully redeem the reward. + # @param reward_id [String] A unique reward ID. + # @param assignment_id [String] A unique reward assignment ID. + # @param [Hash] opts the optional parameters + # @option opts [RewardsAssignmentsUpdateRequestBody] :rewards_assignments_update_request_body Define the number of points required to exchange for the reward. + # @return [Array<(RewardsAssignmentsUpdateResponseBody, Integer, Hash)>] RewardsAssignmentsUpdateResponseBody data, response status code and response headers + private def update_reward_assignment_with_http_info(reward_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RewardsApi.update_reward_assignment ...' + end + # verify the required parameter 'reward_id' is set + if @api_client.config.client_side_validation && reward_id.nil? + fail ArgumentError, "Missing the required parameter 'reward_id' when calling RewardsApi.update_reward_assignment" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling RewardsApi.update_reward_assignment" + end + # resource path + local_var_path = '/v1/rewards/{rewardId}/assignments/{assignmentId}'.sub('{' + 'rewardId' + '}', CGI.escape(reward_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'rewards_assignments_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'RewardsAssignmentsUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"RewardsApi.update_reward_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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RewardsApi#update_reward_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/segments_api.rb b/lib/VoucherifySdk/api/segments_api.rb new file mode 100644 index 00000000..cde4f208 --- /dev/null +++ b/lib/VoucherifySdk/api/segments_api.rb @@ -0,0 +1,83 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class SegmentsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Delete Segment + # This method deletes a customer segment. + # @param segment_id [String] A unique customer segment ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_segment(segment_id, opts = {}) + delete_segment_with_http_info(segment_id, opts) + nil + end + + # Delete Segment + # This method deletes a customer segment. + # @param segment_id [String] A unique customer segment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_segment_with_http_info(segment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SegmentsApi.delete_segment ...' + end + # verify the required parameter 'segment_id' is set + if @api_client.config.client_side_validation && segment_id.nil? + fail ArgumentError, "Missing the required parameter 'segment_id' when calling SegmentsApi.delete_segment" + end + # resource path + local_var_path = '/v1/segments/{segmentId}'.sub('{' + 'segmentId' + '}', CGI.escape(segment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"SegmentsApi.delete_segment", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SegmentsApi#delete_segment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/validation_rules_api.rb b/lib/VoucherifySdk/api/validation_rules_api.rb new file mode 100644 index 00000000..97238643 --- /dev/null +++ b/lib/VoucherifySdk/api/validation_rules_api.rb @@ -0,0 +1,599 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class ValidationRulesApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Validation Rules + # Create validation rules. + # @param [Hash] opts the optional parameters + # @option opts [ValidationRulesCreateRequestBody] :validation_rules_create_request_body Specify the validation rules parameters. + # @return [ValidationRulesCreateResponseBody] + def create_validation_rules(opts = {}) + data, _status_code, _headers = create_validation_rules_with_http_info(opts) + data + end + + # Create Validation Rules + # Create validation rules. + # @param [Hash] opts the optional parameters + # @option opts [ValidationRulesCreateRequestBody] :validation_rules_create_request_body Specify the validation rules parameters. + # @return [Array<(ValidationRulesCreateResponseBody, Integer, Hash)>] ValidationRulesCreateResponseBody data, response status code and response headers + private def create_validation_rules_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.create_validation_rules ...' + end + # resource path + local_var_path = '/v1/validation-rules' + + # query parameters + query_params = opts[:query_params] || {} + + # 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_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ValidationRulesCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.create_validation_rules", + :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_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Validation Rule Assignment + # This method deletes a validation rule assignment. + # @param validation_rule_id [String] A unique validation rule ID. + # @param assignment_id [String] A unique validation rule assignment ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_validation_rule_assignment(validation_rule_id, assignment_id, opts = {}) + delete_validation_rule_assignment_with_http_info(validation_rule_id, assignment_id, opts) + nil + end + + # Delete Validation Rule Assignment + # This method deletes a validation rule assignment. + # @param validation_rule_id [String] A unique validation rule ID. + # @param assignment_id [String] A unique validation rule assignment ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_validation_rule_assignment_with_http_info(validation_rule_id, assignment_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.delete_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.delete_validation_rule_assignment" + end + # verify the required parameter 'assignment_id' is set + if @api_client.config.client_side_validation && assignment_id.nil? + fail ArgumentError, "Missing the required parameter 'assignment_id' when calling ValidationRulesApi.delete_validation_rule_assignment" + end + # resource path + local_var_path = '/v1/validation-rules/{validationRuleId}/assignments/{assignmentId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s)).sub('{' + 'assignmentId' + '}', CGI.escape(assignment_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.delete_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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ValidationRulesApi#delete_validation_rule_assignment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Validation Rule + # This method deletes a validation rule. + # @param validation_rule_id [String] A unique validation rule ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_validation_rules(validation_rule_id, opts = {}) + delete_validation_rules_with_http_info(validation_rule_id, opts) + nil + end + + # Delete Validation Rule + # This method deletes a validation rule. + # @param validation_rule_id [String] A unique validation rule ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_validation_rules_with_http_info(validation_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.delete_validation_rules ...' + 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.delete_validation_rules" + end + # resource path + local_var_path = '/v1/validation-rules/{validationRuleId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.delete_validation_rules", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ValidationRulesApi#delete_validation_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Validation Rule + # Retrieve the details of a validation rule. + # @param validation_rule_id [String] A unique validation rule ID. + # @param [Hash] opts the optional parameters + # @return [ValidationRulesGetResponseBody] + def get_validation_rule(validation_rule_id, opts = {}) + data, _status_code, _headers = get_validation_rule_with_http_info(validation_rule_id, opts) + data + end + + # Get Validation Rule + # Retrieve the details of a validation rule. + # @param validation_rule_id [String] A unique validation rule ID. + # @param [Hash] opts the optional parameters + # @return [Array<(ValidationRulesGetResponseBody, Integer, Hash)>] ValidationRulesGetResponseBody data, response status code and response headers + private def get_validation_rule_with_http_info(validation_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.get_validation_rule ...' + 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.get_validation_rule" + end + # resource path + local_var_path = '/v1/validation-rules/{validationRuleId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ValidationRulesGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.get_validation_rule", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ValidationRulesApi#get_validation_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Validation Rule Assignments + # Retrieve validation rule assignments for a specific validation rule. + # @param validation_rule_id [String] Unique validation rule ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListValidationRuleAssignments] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [ValidationRulesAssignmentsListResponseBody] + def list_validation_rule_assignments(validation_rule_id, opts = {}) + data, _status_code, _headers = list_validation_rule_assignments_with_http_info(validation_rule_id, opts) + data + end + + # List Validation Rule Assignments + # Retrieve validation rule assignments for a specific validation rule. + # @param validation_rule_id [String] Unique validation rule ID. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListValidationRuleAssignments] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @return [Array<(ValidationRulesAssignmentsListResponseBody, Integer, Hash)>] ValidationRulesAssignmentsListResponseBody data, response status code and response headers + private def list_validation_rule_assignments_with_http_info(validation_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.list_validation_rule_assignments ...' + 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.list_validation_rule_assignments" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rule_assignments, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rule_assignments, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ValidationRulesApi.list_validation_rule_assignments, must be smaller than or equal to 100.' + 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[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ValidationRulesAssignmentsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.list_validation_rule_assignments", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ValidationRulesApi#list_validation_rule_assignments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Validation Rules + # Retrieve validation rules. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListValidationRules] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :start_date Timestamp representing the date and time which results must start on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [ValidationRulesListResponseBody] + def list_validation_rules(opts = {}) + data, _status_code, _headers = list_validation_rules_with_http_info(opts) + data + end + + # List Validation Rules + # Retrieve validation rules. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @option opts [ParameterOrderListValidationRules] :order This is a property that controls the sorting direction of the results. Sort the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. + # @option opts [Time] :start_date Timestamp representing the date and time which results must start on. Represented in ISO 8601 format. + # @option opts [Time] :end_date Timestamp representing the date and time which results must end on. Represented in ISO 8601 format. + # @return [Array<(ValidationRulesListResponseBody, Integer, Hash)>] ValidationRulesListResponseBody data, response status code and response headers + private def list_validation_rules_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.list_validation_rules ...' + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rules, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rules, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ValidationRulesApi.list_validation_rules, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/validation-rules' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil? + query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ValidationRulesListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.list_validation_rules", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ValidationRulesApi#list_validation_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Validation Rules' Assignment(s) + # List all validation rules assignments or filter the results using the related object ID or the validation rule ID query parameters. # How to retrieve specific validation rule assignments(s) ## Related object ID To find an assignment for a particular resource, you can use the ID of the object to which the validation rule was assigned. This could be, for example, an ID of a: voucher, campaign, distribution, reward assignment, earning rule, promotion tier. ## Validation rule ID You can use the validation rule ID to find assignment(s) for a specific validation rule. + # @param [Hash] opts the optional parameters + # @option opts [String] :related_object_id The resource ID to which the validation rule was assigned; this could be, for example, a resource ID of a voucher, campaign, earning rule, reward assignment, promotion tier, or distribution. + # @option opts [String] :rule Validation rule ID. + # @option opts [Integer] :page Which page of results to return. + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [String] :order Sorts the results using one of the filtering options: -created_at, created_at, where the dash - preceding a sorting option means sorting in a descending order. + # @return [ValidationRulesAssignmentsListResponseBody] + def list_validation_rules_assignments(opts = {}) + data, _status_code, _headers = list_validation_rules_assignments_with_http_info(opts) + data + end + + # List Validation Rules' Assignment(s) + # List all validation rules assignments or filter the results using the related object ID or the validation rule ID query parameters. # How to retrieve specific validation rule assignments(s) ## Related object ID To find an assignment for a particular resource, you can use the ID of the object to which the validation rule was assigned. This could be, for example, an ID of a: voucher, campaign, distribution, reward assignment, earning rule, promotion tier. ## Validation rule ID You can use the validation rule ID to find assignment(s) for a specific validation rule. + # @param [Hash] opts the optional parameters + # @option opts [String] :related_object_id The resource ID to which the validation rule was assigned; this could be, for example, a resource ID of a voucher, campaign, earning rule, reward assignment, promotion tier, or distribution. + # @option opts [String] :rule Validation rule ID. + # @option opts [Integer] :page Which page of results to return. + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [String] :order Sorts the results using one of the filtering options: -created_at, created_at, where the dash - preceding a sorting option means sorting in a descending order. + # @return [Array<(ValidationRulesAssignmentsListResponseBody, Integer, Hash)>] ValidationRulesAssignmentsListResponseBody data, response status code and response headers + private def list_validation_rules_assignments_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.list_validation_rules_assignments ...' + end + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ValidationRulesApi.list_validation_rules_assignments, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rules_assignments, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ValidationRulesApi.list_validation_rules_assignments, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/v1/validation-rules-assignments' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'related_object_id'] = opts[:'related_object_id'] if !opts[:'related_object_id'].nil? + query_params[:'rule'] = opts[:'rule'] if !opts[:'rule'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ValidationRulesAssignmentsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.list_validation_rules_assignments", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ValidationRulesApi#list_validation_rules_assignments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Validation Rule + # Update validation rule parameters. + # @param validation_rule_id [String] A unique validation rule ID. + # @param [Hash] opts the optional parameters + # @option opts [ValidationRulesUpdateRequestBody] :validation_rules_update_request_body Specify the parameters to be updated. + # @return [ValidationRulesUpdateResponseBody] + def update_validation_rule(validation_rule_id, opts = {}) + data, _status_code, _headers = update_validation_rule_with_http_info(validation_rule_id, opts) + data + end + + # Update Validation Rule + # Update validation rule parameters. + # @param validation_rule_id [String] A unique validation rule ID. + # @param [Hash] opts the optional parameters + # @option opts [ValidationRulesUpdateRequestBody] :validation_rules_update_request_body Specify the parameters to be updated. + # @return [Array<(ValidationRulesUpdateResponseBody, Integer, Hash)>] ValidationRulesUpdateResponseBody data, response status code and response headers + private def update_validation_rule_with_http_info(validation_rule_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationRulesApi.update_validation_rule ...' + 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.update_validation_rule" + end + # resource path + local_var_path = '/v1/validation-rules/{validationRuleId}'.sub('{' + 'validationRuleId' + '}', CGI.escape(validation_rule_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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_update_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ValidationRulesUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationRulesApi.update_validation_rule", + :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(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ValidationRulesApi#update_validation_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/validations_api.rb b/lib/VoucherifySdk/api/validations_api.rb new file mode 100644 index 00000000..68fb3268 --- /dev/null +++ b/lib/VoucherifySdk/api/validations_api.rb @@ -0,0 +1,86 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class ValidationsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Validate Stackable Discounts + # Verify redeemables provided in the request. This method is designed for server side integration which means that it is accessible only through private keys. + # @param [Hash] opts the optional parameters + # @option opts [ValidationsValidateRequestBody] :validations_validate_request_body + # @return [ValidationsValidateResponseBody] + def validate_stacked_discounts(opts = {}) + data, _status_code, _headers = validate_stacked_discounts_with_http_info(opts) + data + end + + # Validate Stackable Discounts + # Verify redeemables provided in the request. This method is designed for server side integration which means that it is accessible only through private keys. + # @param [Hash] opts the optional parameters + # @option opts [ValidationsValidateRequestBody] :validations_validate_request_body + # @return [Array<(ValidationsValidateResponseBody, Integer, Hash)>] ValidationsValidateResponseBody data, response status code and response headers + private def validate_stacked_discounts_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ValidationsApi.validate_stacked_discounts ...' + end + # resource path + local_var_path = '/v1/validations' + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'validations_validate_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'ValidationsValidateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"ValidationsApi.validate_stacked_discounts", + :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: ValidationsApi#validate_stacked_discounts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api/vouchers_api.rb b/lib/VoucherifySdk/api/vouchers_api.rb new file mode 100644 index 00000000..28b87330 --- /dev/null +++ b/lib/VoucherifySdk/api/vouchers_api.rb @@ -0,0 +1,636 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'cgi' + +module VoucherifySdk + class VouchersApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Delete Voucher + # Deletes a voucher. This operation cannot be undone. Additionally, this operation removes any redemptions on the voucher. + # @param code [String] A unique **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the voucher will be removed permanently. Going forward, the user will be able to create another voucher with exactly the same code. + # @return [nil] + def delete_voucher(code, opts = {}) + delete_voucher_with_http_info(code, opts) + nil + end + + # Delete Voucher + # Deletes a voucher. This operation cannot be undone. Additionally, this operation removes any redemptions on the voucher. + # @param code [String] A unique **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @option opts [Boolean] :force If this flag is set to true, the voucher will be removed permanently. Going forward, the user will be able to create another voucher with exactly the same code. + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def delete_voucher_with_http_info(code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.delete_voucher ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.delete_voucher" + end + # resource path + local_var_path = '/v1/vouchers/{code}'.sub('{' + 'code' + '}', CGI.escape(code.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] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.delete_voucher", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: VouchersApi#delete_voucher\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Disable Voucher + # There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - *enable* and *disable*. ___ This method sets the voucher state to **inactive**. The voucher cannot be redeemed. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @return [VouchersDisableResponseBody] + def disable_voucher(code, opts = {}) + data, _status_code, _headers = disable_voucher_with_http_info(code, opts) + data + end + + # Disable Voucher + # There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - *enable* and *disable*. ___ This method sets the voucher state to **inactive**. The voucher cannot be redeemed. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @return [Array<(VouchersDisableResponseBody, Integer, Hash)>] VouchersDisableResponseBody data, response status code and response headers + private def disable_voucher_with_http_info(code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.disable_voucher ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.disable_voucher" + end + # resource path + local_var_path = '/v1/vouchers/{code}/disable'.sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'VouchersDisableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.disable_voucher", + :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: VouchersApi#disable_voucher\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Enable Voucher + # There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - *enable* and *disable*. ___ The method sets the voucher state to **active**. The voucher can be redeemed - only if the redemption occurs after the start date and the voucher is not expired. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @return [VouchersEnableResponseBody] + def enable_voucher(code, opts = {}) + data, _status_code, _headers = enable_voucher_with_http_info(code, opts) + data + end + + # Enable Voucher + # There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - *enable* and *disable*. ___ The method sets the voucher state to **active**. The voucher can be redeemed - only if the redemption occurs after the start date and the voucher is not expired. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @return [Array<(VouchersEnableResponseBody, Integer, Hash)>] VouchersEnableResponseBody data, response status code and response headers + private def enable_voucher_with_http_info(code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.enable_voucher ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.enable_voucher" + end + # resource path + local_var_path = '/v1/vouchers/{code}/enable'.sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'VouchersEnableResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.enable_voucher", + :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: VouchersApi#enable_voucher\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Export Voucher Transactions + # Export transactions that are associated with credit movements on a gift card or loyalty card. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @option opts [VouchersTransactionsExportCreateRequestBody] :vouchers_transactions_export_create_request_body Specify the parameters for the transaction export. + # @return [VouchersTransactionsExportCreateResponseBody] + def export_voucher_transactions(code, opts = {}) + data, _status_code, _headers = export_voucher_transactions_with_http_info(code, opts) + data + end + + # Export Voucher Transactions + # Export transactions that are associated with credit movements on a gift card or loyalty card. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @option opts [VouchersTransactionsExportCreateRequestBody] :vouchers_transactions_export_create_request_body Specify the parameters for the transaction export. + # @return [Array<(VouchersTransactionsExportCreateResponseBody, Integer, Hash)>] VouchersTransactionsExportCreateResponseBody data, response status code and response headers + private def export_voucher_transactions_with_http_info(code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.export_voucher_transactions ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.export_voucher_transactions" + end + # resource path + local_var_path = '/v1/vouchers/{code}/transactions/export'.sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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[:'vouchers_transactions_export_create_request_body']) + + # return_type + return_type = opts[:debug_return_type] || 'VouchersTransactionsExportCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.export_voucher_transactions", + :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: VouchersApi#export_voucher_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Voucher + # Retrieves the voucher with the given code or unique Voucherify ID. You can either pass the voucher ID which was assigned by Voucherify, e.g., v_7HxHkf4VAkMuc8u4lZs78lyRwhRze5UE, or the code of the voucher as the path parameter value, e.g., 7fjWdr. + # @param code [String] A unique **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @return [VouchersGetResponseBody] + def get_voucher(code, opts = {}) + data, _status_code, _headers = get_voucher_with_http_info(code, opts) + data + end + + # Get Voucher + # Retrieves the voucher with the given code or unique Voucherify ID. You can either pass the voucher ID which was assigned by Voucherify, e.g., v_7HxHkf4VAkMuc8u4lZs78lyRwhRze5UE, or the code of the voucher as the path parameter value, e.g., 7fjWdr. + # @param code [String] A unique **code** that identifies the voucher. + # @param [Hash] opts the optional parameters + # @return [Array<(VouchersGetResponseBody, Integer, Hash)>] VouchersGetResponseBody data, response status code and response headers + private def get_voucher_with_http_info(code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.get_voucher ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.get_voucher" + end + # resource path + local_var_path = '/v1/vouchers/{code}'.sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'VouchersGetResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.get_voucher", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: VouchersApi#get_voucher\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Import Vouchers using CSV + # Import standalone vouchers into the repository using a CSV file. The CSV file has to include headers in the first line. All properties listed in the file headers that cannot be mapped to standard voucher fields will be added to the metadata object. You can find an example CSV file [here](https://support.voucherify.io/article/45-import-codes-and-share-them-digitally#coupons). ___ 📘 Standard voucher fields mapping - Go to the import vouchers endpoint to see all standard CSV fields description (body params section). - Supported CSV file headers: Code,Voucher Type,Value,Discount Type,Category,Start Date,Expiration Date,Redemption Limit,Redeemed Quantity, Redeemed Amount,Active,Additional Info,Custom Metadata Property Name - **Start and expiration dates** need to be provided in compliance with the ISO 8601 norms. For example, 2020-03-11T09:00:00.000Z. - YYYY-MM-DD - YYYY-MM-DDTHH - YYYY-MM-DDTHH:mm - YYYY-MM-DDTHH:mm:ss - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ss.SSSZ - Custom code attributes (not supported by-default) need to be added as code **metadata**. - You **cannot import the same codes** to a single Voucherify Project. 📘 Categories In the structure representing your data, you can define a category that the voucher belongs to. You can later use the category of a voucher to group and search by specific criteria in the Dashboard and using the List Vouchers endpoint. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [VouchersImportCsvCreateResponseBody] + def import_vouchers_using_csv(file, opts = {}) + data, _status_code, _headers = import_vouchers_using_csv_with_http_info(file, opts) + data + end + + # Import Vouchers using CSV + # Import standalone vouchers into the repository using a CSV file. The CSV file has to include headers in the first line. All properties listed in the file headers that cannot be mapped to standard voucher fields will be added to the metadata object. You can find an example CSV file [here](https://support.voucherify.io/article/45-import-codes-and-share-them-digitally#coupons). ___ 📘 Standard voucher fields mapping - Go to the import vouchers endpoint to see all standard CSV fields description (body params section). - Supported CSV file headers: Code,Voucher Type,Value,Discount Type,Category,Start Date,Expiration Date,Redemption Limit,Redeemed Quantity, Redeemed Amount,Active,Additional Info,Custom Metadata Property Name - **Start and expiration dates** need to be provided in compliance with the ISO 8601 norms. For example, 2020-03-11T09:00:00.000Z. - YYYY-MM-DD - YYYY-MM-DDTHH - YYYY-MM-DDTHH:mm - YYYY-MM-DDTHH:mm:ss - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ss.SSSZ - Custom code attributes (not supported by-default) need to be added as code **metadata**. - You **cannot import the same codes** to a single Voucherify Project. 📘 Categories In the structure representing your data, you can define a category that the voucher belongs to. You can later use the category of a voucher to group and search by specific criteria in the Dashboard and using the List Vouchers endpoint. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. + # @param file [File] File path. + # @param [Hash] opts the optional parameters + # @return [Array<(VouchersImportCsvCreateResponseBody, Integer, Hash)>] VouchersImportCsvCreateResponseBody data, response status code and response headers + private def import_vouchers_using_csv_with_http_info(file, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.import_vouchers_using_csv ...' + end + # verify the required parameter 'file' is set + if @api_client.config.client_side_validation && file.nil? + fail ArgumentError, "Missing the required parameter 'file' when calling VouchersApi.import_vouchers_using_csv" + end + # resource path + local_var_path = '/v1/vouchers/importCSV' + + # query parameters + query_params = opts[:query_params] || {} + + # 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(['multipart/form-data']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + form_params['file'] = file + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'VouchersImportCsvCreateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.import_vouchers_using_csv", + :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: VouchersApi#import_vouchers_using_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Voucher Transactions + # List transactions that are associated with credit movements on a gift card or loyalty card. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [VouchersTransactionsListResponseBody] + def list_voucher_transactions(code, opts = {}) + data, _status_code, _headers = list_voucher_transactions_with_http_info(code, opts) + data + end + + # List Voucher Transactions + # List transactions that are associated with credit movements on a gift card or loyalty card. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param [Hash] opts the optional parameters + # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. + # @option opts [Integer] :page Which page of results to return. + # @return [Array<(VouchersTransactionsListResponseBody, Integer, Hash)>] VouchersTransactionsListResponseBody data, response status code and response headers + private def list_voucher_transactions_with_http_info(code, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.list_voucher_transactions ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.list_voucher_transactions" + end + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling VouchersApi.list_voucher_transactions, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling VouchersApi.list_voucher_transactions, must be greater than or equal to 1.' + end + + if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 + fail ArgumentError, 'invalid value for "opts[:"page"]" when calling VouchersApi.list_voucher_transactions, must be smaller than or equal to 100.' + end + + # resource path + local_var_path = '/v1/vouchers/{code}/transactions'.sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'VouchersTransactionsListResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.list_voucher_transactions", + :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(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: VouchersApi#list_voucher_transactions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Release Validation Session + # Manually release a validation session that has been set up for the voucher. This method undos the actions that are explained in our guide on how a validation session was established, you can read more here. 📘 Release Session using Dashboard You can also use the Validations Manager in the Dashboard to unlock sessions. [Read more](https://support.voucherify.io/article/16-dashboard-sections#validations). + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify. + # @param session_key [String] A unique session identifier. + # @param [Hash] opts the optional parameters + # @return [nil] + def release_validation_session(code, session_key, opts = {}) + release_validation_session_with_http_info(code, session_key, opts) + nil + end + + # Release Validation Session + # Manually release a validation session that has been set up for the voucher. This method undos the actions that are explained in our guide on how a validation session was established, you can read more here. 📘 Release Session using Dashboard You can also use the Validations Manager in the Dashboard to unlock sessions. [Read more](https://support.voucherify.io/article/16-dashboard-sections#validations). + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify. + # @param session_key [String] A unique session identifier. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + private def release_validation_session_with_http_info(code, session_key, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.release_validation_session ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.release_validation_session" + end + # verify the required parameter 'session_key' is set + if @api_client.config.client_side_validation && session_key.nil? + fail ArgumentError, "Missing the required parameter 'session_key' when calling VouchersApi.release_validation_session" + end + # resource path + local_var_path = '/v1/vouchers/{code}/sessions/{sessionKey}'.sub('{' + 'code' + '}', CGI.escape(code.to_s)).sub('{' + 'sessionKey' + '}', CGI.escape(session_key.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.release_validation_session", + :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(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: VouchersApi#release_validation_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Add or Remove Voucher Balance + # Add balance to an existing gift card or loyalty card. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param vouchers_balance_update_request_body [VouchersBalanceUpdateRequestBody] Provide the amount to be added to/subtracted from the voucher. + # @param [Hash] opts the optional parameters + # @return [VouchersBalanceUpdateResponseBody] + def update_voucher_balance(code, vouchers_balance_update_request_body, opts = {}) + data, _status_code, _headers = update_voucher_balance_with_http_info(code, vouchers_balance_update_request_body, opts) + data + end + + # Add or Remove Voucher Balance + # Add balance to an existing gift card or loyalty card. + # @param code [String] A **code** that identifies the voucher or a unique voucher ID assigned by Voucherify, i.e. v_TzD19aeNiqGc9LWciMWknyEZT8IW7u4u. + # @param vouchers_balance_update_request_body [VouchersBalanceUpdateRequestBody] Provide the amount to be added to/subtracted from the voucher. + # @param [Hash] opts the optional parameters + # @return [Array<(VouchersBalanceUpdateResponseBody, Integer, Hash)>] VouchersBalanceUpdateResponseBody data, response status code and response headers + private def update_voucher_balance_with_http_info(code, vouchers_balance_update_request_body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: VouchersApi.update_voucher_balance ...' + end + # verify the required parameter 'code' is set + if @api_client.config.client_side_validation && code.nil? + fail ArgumentError, "Missing the required parameter 'code' when calling VouchersApi.update_voucher_balance" + end + # verify the required parameter 'vouchers_balance_update_request_body' is set + if @api_client.config.client_side_validation && vouchers_balance_update_request_body.nil? + fail ArgumentError, "Missing the required parameter 'vouchers_balance_update_request_body' when calling VouchersApi.update_voucher_balance" + end + # resource path + local_var_path = '/v1/vouchers/{code}/balance'.sub('{' + 'code' + '}', CGI.escape(code.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # 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(vouchers_balance_update_request_body) + + # return_type + return_type = opts[:debug_return_type] || 'VouchersBalanceUpdateResponseBody' + + # auth_names + auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] + + new_options = opts.merge( + :operation => :"VouchersApi.update_voucher_balance", + :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: VouchersApi#update_voucher_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/VoucherifySdk/api_client.rb b/lib/VoucherifySdk/api_client.rb new file mode 100644 index 00000000..caa8c766 --- /dev/null +++ b/lib/VoucherifySdk/api_client.rb @@ -0,0 +1,392 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'json' +require 'logger' +require 'tempfile' +require 'time' +require 'typhoeus' + +module VoucherifySdk + class ApiClient + # The Configuration object holding settings to be used in the API client. + attr_accessor :config + + # Defines the headers to be used in HTTP requests of all API calls by default. + # + # @return [Hash] + attr_accessor :default_headers + + # Initializes the ApiClient + # @option config [Configuration] Configuration for initializing the object, default to Configuration.default + def initialize(config = Configuration.default) + @config = config + @user_agent = "OpenAPI-Generator/#{VERSION}/ruby" + @default_headers = { + 'Content-Type' => 'application/json', + 'User-Agent' => @user_agent + } + end + + def self.default + @@default ||= ApiClient.new + end + + # Call an API with given options. + # + # @return [Array<(Object, Integer, Hash)>] an array of 3 elements: + # the data deserialized from response body (could be nil), response status code and response headers. + def call_api(http_method, path, opts = {}) + request = build_request(http_method, path, opts) + response = request.run + + if @config.debugging + @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" + end + + unless response.success? + if response.timed_out? + fail ApiError.new('Connection timed out') + elsif response.code == 0 + # Errors from libcurl will be made visible here + fail ApiError.new(:code => 0, + :message => response.return_message) + else + fail ApiError.new(:code => response.code, + :response_headers => response.headers, + :response_body => response.body), + response.status_message + end + end + + if opts[:return_type] + data = deserialize(response, opts[:return_type]) + else + data = nil + end + return data, response.code, response.headers + end + + # Builds the HTTP request + # + # @param [String] http_method HTTP method/verb (e.g. POST) + # @param [String] path URL path (e.g. /account/new) + # @option opts [Hash] :header_params Header parameters + # @option opts [Hash] :query_params Query parameters + # @option opts [Hash] :form_params Query parameters + # @option opts [Object] :body HTTP body (JSON/XML) + # @return [Typhoeus::Request] A Typhoeus Request + def build_request(http_method, path, opts = {}) + url = build_request_url(path, opts) + http_method = http_method.to_sym.downcase + + header_params = @default_headers.merge(opts[:header_params] || {}) + query_params = opts[:query_params] || {} + form_params = opts[:form_params] || {} + follow_location = opts[:follow_location] || true + + update_params_for_auth! header_params, query_params, opts[:auth_names] + + # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false) + _verify_ssl_host = @config.verify_ssl_host ? 2 : 0 + + req_opts = { + :method => http_method, + :headers => header_params, + :params => query_params, + :params_encoding => @config.params_encoding, + :timeout => @config.timeout, + :ssl_verifypeer => @config.verify_ssl, + :ssl_verifyhost => _verify_ssl_host, + :sslcert => @config.cert_file, + :sslkey => @config.key_file, + :verbose => @config.debugging, + :followlocation => follow_location + } + + # set custom cert, if provided + req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert + + if [:post, :patch, :put, :delete].include?(http_method) + req_body = build_request_body(header_params, form_params, opts[:body]) + req_opts.update :body => req_body + if @config.debugging + @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" + end + end + + request = Typhoeus::Request.new(url, req_opts) + download_file(request) if opts[:return_type] == 'File' + request + end + + # Builds the HTTP request body + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [Object] body HTTP body (JSON/XML) + # @return [String] HTTP body data in the form of string + def build_request_body(header_params, form_params, body) + # http form + if header_params['Content-Type'] == 'application/x-www-form-urlencoded' || + header_params['Content-Type'] == 'multipart/form-data' + data = {} + form_params.each do |key, value| + case value + when ::File, ::Array, nil + # let typhoeus handle File, Array and nil parameters + data[key] = value + else + data[key] = value.to_s + end + end + elsif body + data = body.is_a?(String) ? body : body.to_json + else + data = nil + end + data + end + + # Save response body into a file in (the defined) temporary folder, using the filename + # from the "Content-Disposition" header if provided, otherwise a random filename. + # The response body is written to the file in chunks in order to handle files which + # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby + # process can use. + # + # @see Configuration#temp_folder_path + def download_file(request) + tempfile = nil + encoding = nil + request.on_headers do |response| + content_disposition = response.headers['Content-Disposition'] + if content_disposition && content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' + end + prefix = prefix + '-' unless prefix.end_with?('-') + encoding = response.body.encoding + tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + @tempfile = tempfile + end + request.on_body do |chunk| + chunk.force_encoding(encoding) + tempfile.write(chunk) + end + request.on_complete do |response| + if tempfile + tempfile.close + @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ + "will be deleted automatically with GC. It's also recommended to delete the temp file "\ + "explicitly with `tempfile.delete`" + end + end + end + + # Check if the given MIME is a JSON MIME. + # JSON MIME examples: + # application/json + # application/json; charset=UTF8 + # APPLICATION/JSON + # */* + # @param [String] mime MIME + # @return [Boolean] True if the MIME is application/json + def json_mime?(mime) + (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? + end + + # Deserialize the response to the given return type. + # + # @param [Response] response HTTP response + # @param [String] return_type some examples: "User", "Array", "Hash" + def deserialize(response, return_type) + body = response.body + + # handle file downloading - return the File instance processed in request callbacks + # note that response body is empty when the file is written in chunks in request on_body callback + return @tempfile if return_type == 'File' + + return nil if body.nil? || body.empty? + + # return response body directly for String return type + return body if return_type == 'String' + + # ensuring a default content type + content_type = response.headers['Content-Type'] || 'application/json' + + fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type) + + begin + data = JSON.parse("[#{body}]", :symbolize_names => true)[0] + rescue JSON::ParserError => e + if %w(String Date Time).include?(return_type) + data = body + else + raise e + end + end + + convert_to_type data, return_type + end + + # Convert data to the given return type. + # @param [Object] data Data to be converted + # @param [String] return_type Return type + # @return [Mixed] Data in a particular type + def convert_to_type(data, return_type) + return nil if data.nil? + case return_type + when 'String' + data.to_s + when 'Integer' + data.to_i + when 'Float' + data.to_f + when 'Boolean' + data == true + when 'Time' + # parse date time (expecting ISO 8601 format) + Time.parse data + when 'Date' + # parse date time (expecting ISO 8601 format) + Date.parse data + when 'Object' + # generic object (usually a Hash), return directly + data + when /\AArray<(.+)>\z/ + # e.g. Array + sub_type = $1 + data.map { |item| convert_to_type(item, sub_type) } + when /\AHash\\z/ + # e.g. Hash + sub_type = $1 + {}.tap do |hash| + data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } + end + else + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(return_type) + klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) + end + end + + # Sanitize filename by removing path. + # e.g. ../../sun.gif becomes sun.gif + # + # @param [String] filename the filename to be sanitized + # @return [String] the sanitized filename + def sanitize_filename(filename) + filename.gsub(/.*[\/\\]/, '') + end + + def build_request_url(path, opts = {}) + # Add leading and trailing slashes to path + path = "/#{path}".gsub(/\/+/, '/') + @config.base_url(opts[:operation]) + path + end + + # Update header and query params based on authentication settings. + # + # @param [Hash] header_params Header parameters + # @param [Hash] query_params Query parameters + # @param [String] auth_names Authentication scheme name + def update_params_for_auth!(header_params, query_params, auth_names) + Array(auth_names).each do |auth_name| + auth_setting = @config.auth_settings[auth_name] + next unless auth_setting + case auth_setting[:in] + when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] + when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] + else fail ArgumentError, 'Authentication token must be in `query` or `header`' + end + end + end + + # Sets user agent in HTTP header + # + # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0) + def user_agent=(user_agent) + @user_agent = user_agent + @default_headers['User-Agent'] = @user_agent + end + + # Return Accept header based on an array of accepts provided. + # @param [Array] accepts array for Accept + # @return [String] the Accept header (e.g. application/json) + def select_header_accept(accepts) + return nil if accepts.nil? || accepts.empty? + # use JSON when present, otherwise use all of the provided + json_accept = accepts.find { |s| json_mime?(s) } + json_accept || accepts.join(',') + end + + # Return Content-Type header based on an array of content types provided. + # @param [Array] content_types array for Content-Type + # @return [String] the Content-Type header (e.g. application/json) + def select_header_content_type(content_types) + # return nil by default + return if content_types.nil? || content_types.empty? + # use JSON when present, otherwise use the first one + json_content_type = content_types.find { |s| json_mime?(s) } + json_content_type || content_types.first + end + + # Convert object (array, hash, object, etc) to JSON string. + # @param [Object] model object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_http_body(model) + return model if model.nil? || model.is_a?(String) + local_body = nil + if model.is_a?(Array) + local_body = model.map { |m| object_to_hash(m) } + else + local_body = object_to_hash(model) + end + local_body.to_json + end + + # Convert object(non-array) to hash. + # @param [Object] obj object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_hash(obj) + if obj.respond_to?(:to_hash) + obj.to_hash + else + obj + end + end + + # Build parameter value according to the given collection format. + # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi + def build_collection_param(param, collection_format) + case collection_format + when :csv + param.join(',') + when :ssv + param.join(' ') + when :tsv + param.join("\t") + when :pipes + param.join('|') + when :multi + # return the array directly as typhoeus will handle it as expected + param + else + fail "unknown collection format: #{collection_format.inspect}" + end + end + end +end diff --git a/lib/VoucherifySdk/api_error.rb b/lib/VoucherifySdk/api_error.rb new file mode 100644 index 00000000..04901e36 --- /dev/null +++ b/lib/VoucherifySdk/api_error.rb @@ -0,0 +1,58 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +module VoucherifySdk + class ApiError < StandardError + attr_reader :code, :response_headers, :response_body + + # Usage examples: + # ApiError.new + # ApiError.new("message") + # ApiError.new(:code => 500, :response_headers => {}, :response_body => "") + # ApiError.new(:code => 404, :message => "Not Found") + def initialize(arg = nil) + if arg.is_a? Hash + if arg.key?(:message) || arg.key?('message') + super(arg[:message] || arg['message']) + else + super arg + end + + arg.each do |k, v| + instance_variable_set "@#{k}", v + end + else + super arg + @message = arg + end + end + + # Override to_s to display a friendly error message + def to_s + message + end + + def message + if @message.nil? + msg = "Error message: the server returns an error" + else + msg = @message + end + + msg += "\nHTTP status code: #{code}" if code + msg += "\nResponse headers: #{response_headers}" if response_headers + msg += "\nResponse body: #{response_body}" if response_body + + msg + end + end +end diff --git a/lib/VoucherifySdk/configuration.rb b/lib/VoucherifySdk/configuration.rb new file mode 100644 index 00000000..1bb8b480 --- /dev/null +++ b/lib/VoucherifySdk/configuration.rb @@ -0,0 +1,332 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +module VoucherifySdk + class Configuration + # Defines url scheme + attr_accessor :scheme + + # Defines url host + attr_accessor :host + + # Defines url base path + attr_accessor :base_path + + # Define server configuration index + attr_accessor :server_index + + # Define server operation configuration index + attr_accessor :server_operation_index + + # Default server variables + attr_accessor :server_variables + + # Default server operation variables + attr_accessor :server_operation_variables + + # Defines API keys used with API Key authentications. + # + # @return [Hash] key: parameter name, value: parameter value (API key) + # + # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string) + # config.api_key['api_key'] = 'xxx' + attr_accessor :api_key + + # Defines API key prefixes used with API Key authentications. + # + # @return [Hash] key: parameter name, value: API key prefix + # + # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers) + # config.api_key_prefix['api_key'] = 'Token' + attr_accessor :api_key_prefix + + # Defines the username used with HTTP basic authentication. + # + # @return [String] + attr_accessor :username + + # Defines the password used with HTTP basic authentication. + # + # @return [String] + attr_accessor :password + + # Defines the access token (Bearer) used with OAuth2. + attr_accessor :access_token + + # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2. + # Overrides the access_token if set + # @return [Proc] + attr_accessor :access_token_getter + + # Set this to return data as binary instead of downloading a temp file. When enabled (set to true) + # HTTP responses with return type `File` will be returned as a stream of binary data. + # Default to false. + attr_accessor :return_binary_data + + # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response + # details will be logged with `logger.debug` (see the `logger` attribute). + # Default to false. + # + # @return [true, false] + attr_accessor :debugging + + # Defines the logger used for debugging. + # Default to `Rails.logger` (when in Rails) or logging to STDOUT. + # + # @return [#debug] + attr_accessor :logger + + # Defines the temporary folder to store downloaded files + # (for API endpoints that have file response). + # Default to use `Tempfile`. + # + # @return [String] + attr_accessor :temp_folder_path + + # The time limit for HTTP request in seconds. + # Default to 0 (never times out). + attr_accessor :timeout + + # Set this to false to skip client side validation in the operation. + # Default to true. + # @return [true, false] + attr_accessor :client_side_validation + + ### TLS/SSL setting + # Set this to false to skip verifying SSL certificate when calling API from https server. + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :verify_ssl + + ### TLS/SSL setting + # Set this to false to skip verifying SSL host name + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :verify_ssl_host + + ### TLS/SSL setting + # Set this to customize the certificate file to verify the peer. + # + # @return [String] the path to the certificate file + # + # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code: + # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145 + attr_accessor :ssl_ca_cert + + ### TLS/SSL setting + # Client certificate file (for client certificate) + attr_accessor :cert_file + + ### TLS/SSL setting + # Client private key file (for client certificate) + attr_accessor :key_file + + # Set this to customize parameters encoding of array parameter with multi collectionFormat. + # Default to nil. + # + # @see The params_encoding option of Ethon. Related source code: + # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96 + attr_accessor :params_encoding + + + attr_accessor :inject_format + + attr_accessor :force_ending_format + + def initialize + @scheme = 'https' + @host = 'api.voucherify.io' + @base_path = '' + @server_index = nil + @server_operation_index = {} + @server_variables = {} + @server_operation_variables = {} + @api_key = {} + @api_key_prefix = {} + @client_side_validation = true + @verify_ssl = true + @verify_ssl_host = true + @cert_file = nil + @key_file = nil + @timeout = 0 + @params_encoding = nil + @debugging = false + @inject_format = false + @force_ending_format = false + @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) + + yield(self) if block_given? + end + + # The default Configuration object. + def self.default + @@default ||= Configuration.new + end + + def configure + yield(self) if block_given? + end + + def scheme=(scheme) + # remove :// from scheme + @scheme = scheme.sub(/:\/\//, '') + end + + def host=(host) + # remove http(s):// and anything after a slash + @host = host.sub(/https?:\/\//, '').split('/').first + end + + def base_path=(base_path) + # Add leading and trailing slashes to base_path + @base_path = "/#{base_path}".gsub(/\/+/, '/') + @base_path = '' if @base_path == '/' + end + + # Returns base URL for specified operation based on server settings + def base_url(operation = nil) + if operation_server_settings.key?(operation) then + index = server_operation_index.fetch(operation, server_index) + server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation]) + else + server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil) + end + end + + # Gets API key (with prefix if set). + # @param [String] param_name the parameter name of API key auth + def api_key_with_prefix(param_name, param_alias = nil) + key = @api_key[param_name] + key = @api_key.fetch(param_alias, key) unless param_alias.nil? + if @api_key_prefix[param_name] + "#{@api_key_prefix[param_name]} #{key}" + else + key + end + end + + # Gets access_token using access_token_getter or uses the static access_token + def access_token_with_refresh + return access_token if access_token_getter.nil? + access_token_getter.call + end + + # Gets Basic Auth token string + def basic_auth_token + 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n") + end + + # Returns Auth Settings hash for api client. + def auth_settings + { + 'X-App-Id' => + { + type: 'api_key', + in: 'header', + key: 'X-App-Id', + value: api_key_with_prefix('X-App-Id') + }, + 'X-App-Token' => + { + type: 'api_key', + in: 'header', + key: 'X-App-Token', + value: api_key_with_prefix('X-App-Token') + }, + 'X-Client-Token' => + { + type: 'api_key', + in: 'header', + key: 'X-Client-Token', + value: api_key_with_prefix('X-Client-Token') + }, + 'X-Client-Application-Id' => + { + type: 'api_key', + in: 'header', + key: 'X-Client-Application-Id', + value: api_key_with_prefix('X-Client-Application-Id') + }, + } + end + + # Returns an array of Server setting + def server_settings + [ + { + url: "https://{cluster}.voucherify.io", + description: "Base URL", + variables: { + cluster: { + description: "No description provided", + default_value: "api", + enum_values: [ + "api", + "us1.api", + "as1.api", + "download", + "us1.download", + "as1.download" + ] + } + } + } + ] + end + + def operation_server_settings + { + } + end + + # Returns URL based on server settings + # + # @param index array index of the server settings + # @param variables hash of variable and the corresponding value + def server_url(index, variables = {}, servers = nil) + servers = server_settings if servers == nil + + # check array index out of bound + if (index.nil? || index < 0 || index >= servers.size) + fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}" + end + + server = servers[index] + url = server[:url] + + return url unless server.key? :variables + + # go through variable and assign a value + server[:variables].each do |name, variable| + if variables.key?(name) + if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name])) + url.gsub! "{" + name.to_s + "}", variables[name] + else + fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}." + end + else + # use default value + url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value] + end + end + + url + end + + end +end diff --git a/lib/VoucherifySdk/models/any.rb b/lib/VoucherifySdk/models/any.rb new file mode 100644 index 00000000..0454e9c3 --- /dev/null +++ b/lib/VoucherifySdk/models/any.rb @@ -0,0 +1,107 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module Any + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'Array', + :'Float', + :'Object', + :'String' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/applicable_to.rb b/lib/VoucherifySdk/models/applicable_to.rb new file mode 100644 index 00000000..09016d80 --- /dev/null +++ b/lib/VoucherifySdk/models/applicable_to.rb @@ -0,0 +1,406 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ApplicableTo + # This object stores information about the product collection. + attr_accessor :object + + # Unique product collection ID assigned by Voucherify. + attr_accessor :id + + # The source ID from your inventory system. + attr_accessor :source_id + + # Parent product's unique ID assigned by Voucherify. + attr_accessor :product_id + + # Parent product's source ID from your inventory system. + attr_accessor :product_source_id + + attr_accessor :strict + + # New fixed price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 price is written as 1000. In case of the fixed price being calculated by the formula, i.e. the price_formula parameter is present in the fixed price definition, this value becomes the fallback value. Such that in a case where the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed price. + attr_accessor :price + + # Formula used to calculate the discounted price of an item. + attr_accessor :price_formula + + attr_accessor :effect + + # The maximum number of units allowed to be discounted per order line item. + attr_accessor :quantity_limit + + # The maximum number of units allowed to be discounted combined across all matched order line items. + attr_accessor :aggregated_quantity_limit + + # Upper limit allowed to be applied as a discount per order line item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600. + attr_accessor :amount_limit + + # Maximum discount amount per order. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount on the entire order is written as 600. This value is definable for the following discount effects: - `APPLY_TO_ITEMS` (each item subtotal is discounted equally) - `APPLY_TO_ITEMS_BY_QUANTITY` (each unit of matched products has the same discount value) + attr_accessor :aggregated_amount_limit + + attr_accessor :order_item_indices + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'product_source_id' => :'product_source_id', + :'strict' => :'strict', + :'price' => :'price', + :'price_formula' => :'price_formula', + :'effect' => :'effect', + :'quantity_limit' => :'quantity_limit', + :'aggregated_quantity_limit' => :'aggregated_quantity_limit', + :'amount_limit' => :'amount_limit', + :'aggregated_amount_limit' => :'aggregated_amount_limit', + :'order_item_indices' => :'order_item_indices' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'product_source_id' => :'String', + :'strict' => :'Boolean', + :'price' => :'Float', + :'price_formula' => :'Float', + :'effect' => :'ApplicableToEffect', + :'quantity_limit' => :'Integer', + :'aggregated_quantity_limit' => :'Integer', + :'amount_limit' => :'Integer', + :'aggregated_amount_limit' => :'Integer', + :'order_item_indices' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ApplicableTo` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ApplicableTo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'product_source_id') + self.product_source_id = attributes[:'product_source_id'] + end + + if attributes.key?(:'strict') + self.strict = attributes[:'strict'] + else + self.strict = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'price_formula') + self.price_formula = attributes[:'price_formula'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + else + self.effect = nil + end + + if attributes.key?(:'quantity_limit') + self.quantity_limit = attributes[:'quantity_limit'] + end + + if attributes.key?(:'aggregated_quantity_limit') + self.aggregated_quantity_limit = attributes[:'aggregated_quantity_limit'] + end + + if attributes.key?(:'amount_limit') + self.amount_limit = attributes[:'amount_limit'] + end + + if attributes.key?(:'aggregated_amount_limit') + self.aggregated_amount_limit = attributes[:'aggregated_amount_limit'] + end + + if attributes.key?(:'order_item_indices') + if (value = attributes[:'order_item_indices']).is_a?(Array) + self.order_item_indices = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @strict.nil? + invalid_properties.push('invalid value for "strict", strict cannot be nil.') + end + + if @effect.nil? + invalid_properties.push('invalid value for "effect", effect cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product", "sku", "products_collection"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + return false if @strict.nil? + return false if @effect.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product", "sku", "products_collection"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + product_source_id == o.product_source_id && + strict == o.strict && + price == o.price && + price_formula == o.price_formula && + effect == o.effect && + quantity_limit == o.quantity_limit && + aggregated_quantity_limit == o.aggregated_quantity_limit && + amount_limit == o.amount_limit && + aggregated_amount_limit == o.aggregated_amount_limit && + order_item_indices == o.order_item_indices + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, id, source_id, product_id, product_source_id, strict, price, price_formula, effect, quantity_limit, aggregated_quantity_limit, amount_limit, aggregated_amount_limit, order_item_indices].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/applicable_to_effect.rb b/lib/VoucherifySdk/models/applicable_to_effect.rb new file mode 100644 index 00000000..a30b069d --- /dev/null +++ b/lib/VoucherifySdk/models/applicable_to_effect.rb @@ -0,0 +1,41 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ApplicableToEffect + EVERY = "APPLY_TO_EVERY".freeze + CHEAPEST = "APPLY_TO_CHEAPEST".freeze + MOST_EXPENSIVE = "APPLY_TO_MOST_EXPENSIVE".freeze + + def self.all_vars + @all_vars ||= [EVERY, CHEAPEST, MOST_EXPENSIVE].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ApplicableToEffect.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ApplicableToEffect" + end + end +end diff --git a/lib/VoucherifySdk/models/applicable_to_result_list.rb b/lib/VoucherifySdk/models/applicable_to_result_list.rb new file mode 100644 index 00000000..328f7118 --- /dev/null +++ b/lib/VoucherifySdk/models/applicable_to_result_list.rb @@ -0,0 +1,340 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ApplicableToResultList + # Contains array of items to which the discount can apply. + attr_accessor :data + + # Total number of objects defining included products, SKUs, or product collections. + attr_accessor :total + + # The type of object represented by JSON. + attr_accessor :object + + # The type of object represented by JSON. + attr_accessor :data_ref + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'total' => :'total', + :'object' => :'object', + :'data_ref' => :'data_ref' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'total' => :'Integer', + :'object' => :'String', + :'data_ref' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ApplicableToResultList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ApplicableToResultList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @total < 0 + invalid_properties.push('invalid value for "total", must be greater than or equal to 0.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @data.nil? + return false if @total.nil? + return false if @total < 0 + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + true + end + + # Custom attribute writer method with validation + # @param [Object] total Value to be assigned + def total=(total) + if total.nil? + fail ArgumentError, 'total cannot be nil' + end + + if total < 0 + fail ArgumentError, 'invalid value for "total", must be greater than or equal to 0.' + end + + @total = total + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + total == o.total && + object == o.object && + data_ref == o.data_ref + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, total, object, data_ref].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/array_inner.rb b/lib/VoucherifySdk/models/array_inner.rb new file mode 100644 index 00000000..16bcdede --- /dev/null +++ b/lib/VoucherifySdk/models/array_inner.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module ArrayInner + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'Float', + :'Object', + :'String' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/async_actions.rb b/lib/VoucherifySdk/models/async_actions.rb new file mode 100644 index 00000000..f12d63f8 --- /dev/null +++ b/lib/VoucherifySdk/models/async_actions.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response to requests that are processed asynchronously. + class AsyncActions + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::AsyncActions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::AsyncActions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/bus_val_rule_assignment.rb b/lib/VoucherifySdk/models/bus_val_rule_assignment.rb new file mode 100644 index 00000000..03f18bc7 --- /dev/null +++ b/lib/VoucherifySdk/models/bus_val_rule_assignment.rb @@ -0,0 +1,379 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Assignments of business validation rule + class BusValRuleAssignment + # The unique identifier for a assignment + attr_accessor :id + + # The unique identifier for a rule + attr_accessor :rule_id + + # The unique identifier for a related object + attr_accessor :related_object_id + + # The type of related object + attr_accessor :related_object_type + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the object was last updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. + attr_accessor :object + + # The validation status of the assignment + attr_accessor :validation_status + + # The list of omitted rules + attr_accessor :validation_omitted_rules + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'rule_id' => :'rule_id', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'validation_status' => :'validation_status', + :'validation_omitted_rules' => :'validation_omitted_rules' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'rule_id' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'validation_status' => :'String', + :'validation_omitted_rules' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::BusValRuleAssignment` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::BusValRuleAssignment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'rule_id') + self.rule_id = attributes[:'rule_id'] + else + self.rule_id = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'validation_rules_assignment' + end + + if attributes.key?(:'validation_status') + self.validation_status = attributes[:'validation_status'] + end + + if attributes.key?(:'validation_omitted_rules') + if (value = attributes[:'validation_omitted_rules']).is_a?(Array) + self.validation_omitted_rules = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @rule_id.nil? + invalid_properties.push('invalid value for "rule_id", rule_id cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @rule_id.nil? + return false if @related_object_id.nil? + return false if @related_object_type.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["validation_rules_assignment"]) + return false unless object_validator.valid?(@object) + validation_status_validator = EnumAttributeValidator.new('String', ["VALID", "PARTIALLY_VALID", "INVALID"]) + return false unless validation_status_validator.valid?(@validation_status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["validation_rules_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] validation_status Object to be assigned + def validation_status=(validation_status) + validator = EnumAttributeValidator.new('String', ["VALID", "PARTIALLY_VALID", "INVALID"]) + unless validator.valid?(validation_status) + fail ArgumentError, "invalid value for \"validation_status\", must be one of #{validator.allowable_values}." + end + @validation_status = validation_status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + rule_id == o.rule_id && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + validation_status == o.validation_status && + validation_omitted_rules == o.validation_omitted_rules + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, rule_id, related_object_id, related_object_type, created_at, updated_at, object, validation_status, validation_omitted_rules].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign.rb b/lib/VoucherifySdk/models/campaign.rb new file mode 100644 index 00000000..5290a4c8 --- /dev/null +++ b/lib/VoucherifySdk/models/campaign.rb @@ -0,0 +1,674 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class Campaign + # Unique campaign ID, assigned by Voucherify. + attr_accessor :id + + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Type of campaign. + attr_accessor :campaign_type + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published + attr_accessor :type + + attr_accessor :voucher + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Total number of unique vouchers in campaign. + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + # A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign + attr_accessor :active + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the campaign was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique category name. + attr_accessor :category + + # Indicates the status of the campaign creation. + attr_accessor :creation_status + + # Indicates the status of the campaign's vouchers. + attr_accessor :vouchers_generation_status + + # Indicates whether the resource can be deleted. + attr_accessor :protected + + # Unique category ID that this campaign belongs to. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # The type of object represented by JSON. This object stores information about the campaign. + attr_accessor :object + + attr_accessor :referral_program + + attr_accessor :loyalty_tiers_expiration + + attr_accessor :promotion + + attr_accessor :validation_rules_assignments + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'campaign_type' => :'campaign_type', + :'type' => :'type', + :'voucher' => :'voucher', + :'auto_join' => :'auto_join', + :'join_once' => :'join_once', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'active' => :'active', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'category' => :'category', + :'creation_status' => :'creation_status', + :'vouchers_generation_status' => :'vouchers_generation_status', + :'protected' => :'protected', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'object' => :'object', + :'referral_program' => :'referral_program', + :'loyalty_tiers_expiration' => :'loyalty_tiers_expiration', + :'promotion' => :'promotion', + :'validation_rules_assignments' => :'validation_rules_assignments' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'campaign_type' => :'String', + :'type' => :'String', + :'voucher' => :'CampaignVoucher', + :'auto_join' => :'Boolean', + :'join_once' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'active' => :'Boolean', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'category' => :'String', + :'creation_status' => :'String', + :'vouchers_generation_status' => :'String', + :'protected' => :'Boolean', + :'category_id' => :'String', + :'categories' => :'Array', + :'object' => :'String', + :'referral_program' => :'ReferralProgram', + :'loyalty_tiers_expiration' => :'LoyaltyTiersExpirationAll', + :'promotion' => :'PromotionTiersList', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Campaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Campaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + else + self.auto_join = nil + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + else + self.join_once = nil + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + else + self.use_voucher_metadata_schema = nil + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'creation_status') + self.creation_status = attributes[:'creation_status'] + else + self.creation_status = nil + end + + if attributes.key?(:'vouchers_generation_status') + self.vouchers_generation_status = attributes[:'vouchers_generation_status'] + else + self.vouchers_generation_status = nil + end + + if attributes.key?(:'protected') + self.protected = attributes[:'protected'] + else + self.protected = nil + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'campaign' + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + + if attributes.key?(:'loyalty_tiers_expiration') + self.loyalty_tiers_expiration = attributes[:'loyalty_tiers_expiration'] + end + + if attributes.key?(:'promotion') + self.promotion = attributes[:'promotion'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @campaign_type.nil? + invalid_properties.push('invalid value for "campaign_type", campaign_type cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @auto_join.nil? + invalid_properties.push('invalid value for "auto_join", auto_join cannot be nil.') + end + + if @join_once.nil? + invalid_properties.push('invalid value for "join_once", join_once cannot be nil.') + end + + if @use_voucher_metadata_schema.nil? + invalid_properties.push('invalid value for "use_voucher_metadata_schema", use_voucher_metadata_schema cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @creation_status.nil? + invalid_properties.push('invalid value for "creation_status", creation_status cannot be nil.') + end + + if @vouchers_generation_status.nil? + invalid_properties.push('invalid value for "vouchers_generation_status", vouchers_generation_status cannot be nil.') + end + + if @protected.nil? + invalid_properties.push('invalid value for "protected", protected cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @campaign_type.nil? + campaign_type_validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + return false unless campaign_type_validator.valid?(@campaign_type) + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if @auto_join.nil? + return false if @join_once.nil? + return false if @use_voucher_metadata_schema.nil? + return false if @created_at.nil? + return false if @creation_status.nil? + creation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless creation_status_validator.valid?(@creation_status) + return false if @vouchers_generation_status.nil? + vouchers_generation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless vouchers_generation_status_validator.valid?(@vouchers_generation_status) + return false if @protected.nil? + return false if @categories.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] creation_status Object to be assigned + def creation_status=(creation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(creation_status) + fail ArgumentError, "invalid value for \"creation_status\", must be one of #{validator.allowable_values}." + end + @creation_status = creation_status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] vouchers_generation_status Object to be assigned + def vouchers_generation_status=(vouchers_generation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(vouchers_generation_status) + fail ArgumentError, "invalid value for \"vouchers_generation_status\", must be one of #{validator.allowable_values}." + end + @vouchers_generation_status = vouchers_generation_status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + description == o.description && + campaign_type == o.campaign_type && + type == o.type && + voucher == o.voucher && + auto_join == o.auto_join && + join_once == o.join_once && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + active == o.active && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + category == o.category && + creation_status == o.creation_status && + vouchers_generation_status == o.vouchers_generation_status && + protected == o.protected && + category_id == o.category_id && + categories == o.categories && + object == o.object && + referral_program == o.referral_program && + loyalty_tiers_expiration == o.loyalty_tiers_expiration && + promotion == o.promotion && + validation_rules_assignments == o.validation_rules_assignments + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, description, campaign_type, type, voucher, auto_join, join_once, use_voucher_metadata_schema, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, vouchers_count, start_date, expiration_date, active, metadata, created_at, updated_at, category, creation_status, vouchers_generation_status, protected, category_id, categories, object, referral_program, loyalty_tiers_expiration, promotion, validation_rules_assignments].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_base.rb b/lib/VoucherifySdk/models/campaign_base.rb new file mode 100644 index 00000000..b6b815b1 --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_base.rb @@ -0,0 +1,650 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a campaign. + class CampaignBase + # Unique campaign ID, assigned by Voucherify. + attr_accessor :id + + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Type of campaign. + attr_accessor :campaign_type + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published + attr_accessor :type + + attr_accessor :voucher + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Total number of unique vouchers in campaign. + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + # A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign + attr_accessor :active + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the campaign was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique category name. + attr_accessor :category + + # Indicates the status of the campaign creation. + attr_accessor :creation_status + + # Indicates the status of the campaign's vouchers. + attr_accessor :vouchers_generation_status + + # Indicates whether the resource can be deleted. + attr_accessor :protected + + # Unique category ID that this campaign belongs to. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # The type of object represented by JSON. This object stores information about the campaign. + attr_accessor :object + + attr_accessor :referral_program + + attr_accessor :loyalty_tiers_expiration + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'campaign_type' => :'campaign_type', + :'type' => :'type', + :'voucher' => :'voucher', + :'auto_join' => :'auto_join', + :'join_once' => :'join_once', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'active' => :'active', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'category' => :'category', + :'creation_status' => :'creation_status', + :'vouchers_generation_status' => :'vouchers_generation_status', + :'protected' => :'protected', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'object' => :'object', + :'referral_program' => :'referral_program', + :'loyalty_tiers_expiration' => :'loyalty_tiers_expiration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'campaign_type' => :'String', + :'type' => :'String', + :'voucher' => :'CampaignVoucher', + :'auto_join' => :'Boolean', + :'join_once' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'active' => :'Boolean', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'category' => :'String', + :'creation_status' => :'String', + :'vouchers_generation_status' => :'String', + :'protected' => :'Boolean', + :'category_id' => :'String', + :'categories' => :'Array', + :'object' => :'String', + :'referral_program' => :'ReferralProgram', + :'loyalty_tiers_expiration' => :'LoyaltyTiersExpirationAll' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + else + self.auto_join = nil + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + else + self.join_once = nil + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + else + self.use_voucher_metadata_schema = nil + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'creation_status') + self.creation_status = attributes[:'creation_status'] + else + self.creation_status = nil + end + + if attributes.key?(:'vouchers_generation_status') + self.vouchers_generation_status = attributes[:'vouchers_generation_status'] + else + self.vouchers_generation_status = nil + end + + if attributes.key?(:'protected') + self.protected = attributes[:'protected'] + else + self.protected = nil + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'campaign' + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + + if attributes.key?(:'loyalty_tiers_expiration') + self.loyalty_tiers_expiration = attributes[:'loyalty_tiers_expiration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @campaign_type.nil? + invalid_properties.push('invalid value for "campaign_type", campaign_type cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @auto_join.nil? + invalid_properties.push('invalid value for "auto_join", auto_join cannot be nil.') + end + + if @join_once.nil? + invalid_properties.push('invalid value for "join_once", join_once cannot be nil.') + end + + if @use_voucher_metadata_schema.nil? + invalid_properties.push('invalid value for "use_voucher_metadata_schema", use_voucher_metadata_schema cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @creation_status.nil? + invalid_properties.push('invalid value for "creation_status", creation_status cannot be nil.') + end + + if @vouchers_generation_status.nil? + invalid_properties.push('invalid value for "vouchers_generation_status", vouchers_generation_status cannot be nil.') + end + + if @protected.nil? + invalid_properties.push('invalid value for "protected", protected cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @campaign_type.nil? + campaign_type_validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + return false unless campaign_type_validator.valid?(@campaign_type) + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if @auto_join.nil? + return false if @join_once.nil? + return false if @use_voucher_metadata_schema.nil? + return false if @created_at.nil? + return false if @creation_status.nil? + creation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless creation_status_validator.valid?(@creation_status) + return false if @vouchers_generation_status.nil? + vouchers_generation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless vouchers_generation_status_validator.valid?(@vouchers_generation_status) + return false if @protected.nil? + return false if @categories.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] creation_status Object to be assigned + def creation_status=(creation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(creation_status) + fail ArgumentError, "invalid value for \"creation_status\", must be one of #{validator.allowable_values}." + end + @creation_status = creation_status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] vouchers_generation_status Object to be assigned + def vouchers_generation_status=(vouchers_generation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(vouchers_generation_status) + fail ArgumentError, "invalid value for \"vouchers_generation_status\", must be one of #{validator.allowable_values}." + end + @vouchers_generation_status = vouchers_generation_status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + description == o.description && + campaign_type == o.campaign_type && + type == o.type && + voucher == o.voucher && + auto_join == o.auto_join && + join_once == o.join_once && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + active == o.active && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + category == o.category && + creation_status == o.creation_status && + vouchers_generation_status == o.vouchers_generation_status && + protected == o.protected && + category_id == o.category_id && + categories == o.categories && + object == o.object && + referral_program == o.referral_program && + loyalty_tiers_expiration == o.loyalty_tiers_expiration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, description, campaign_type, type, voucher, auto_join, join_once, use_voucher_metadata_schema, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, vouchers_count, start_date, expiration_date, active, metadata, created_at, updated_at, category, creation_status, vouchers_generation_status, protected, category_id, categories, object, referral_program, loyalty_tiers_expiration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_base_validity_timeframe.rb b/lib/VoucherifySdk/models/campaign_base_validity_timeframe.rb new file mode 100644 index 00000000..d685fe5d --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_base_validity_timeframe.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Set recurrent time periods when the campaign is valid. For example, valid for 1 hour every other day.`start_date` **required** when including the `validity_timeframe`. + class CampaignBaseValidityTimeframe + # Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a campaign with an `interval` of `P2D` will be active every other day. + attr_accessor :interval + + # Defines the amount of time the campaign will be active in ISO 8601 format. For example, a campaign with a `duration` of `P1D` will be valid for a duration of one day. + attr_accessor :duration + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'interval' => :'interval', + :'duration' => :'duration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'interval' => :'String', + :'duration' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignBaseValidityTimeframe` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignBaseValidityTimeframe`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'interval') + self.interval = attributes[:'interval'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + interval == o.interval && + duration == o.duration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [interval, duration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_loyalty_card.rb b/lib/VoucherifySdk/models/campaign_loyalty_card.rb new file mode 100644 index 00000000..ed91af53 --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_loyalty_card.rb @@ -0,0 +1,232 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema model for a campaign loyalty card. + class CampaignLoyaltyCard + # The initial number of points to assign to the loyalty card. This is the current loyalty card score i.e. the number of loyalty points on the card. + attr_accessor :points + + attr_accessor :expiration_rules + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'expiration_rules' => :'expiration_rules' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'expiration_rules' => :'CampaignLoyaltyCardExpirationRules' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'expiration_rules') + self.expiration_rules = attributes[:'expiration_rules'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + expiration_rules == o.expiration_rules + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, expiration_rules].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_loyalty_card_expiration_rules.rb b/lib/VoucherifySdk/models/campaign_loyalty_card_expiration_rules.rb new file mode 100644 index 00000000..b0a362cf --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_loyalty_card_expiration_rules.rb @@ -0,0 +1,273 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignLoyaltyCardExpirationRules + # Type of period + attr_accessor :period_type + + # Value of the period + attr_accessor :period_value + + # Type of rounding + attr_accessor :rounding_type + + # Value of rounding + attr_accessor :rounding_value + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'period_type' => :'period_type', + :'period_value' => :'period_value', + :'rounding_type' => :'rounding_type', + :'rounding_value' => :'rounding_value' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'period_type' => :'String', + :'period_value' => :'Integer', + :'rounding_type' => :'String', + :'rounding_value' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignLoyaltyCardExpirationRules` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignLoyaltyCardExpirationRules`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'period_type') + self.period_type = attributes[:'period_type'] + else + self.period_type = nil + end + + if attributes.key?(:'period_value') + self.period_value = attributes[:'period_value'] + else + self.period_value = nil + end + + if attributes.key?(:'rounding_type') + self.rounding_type = attributes[:'rounding_type'] + else + self.rounding_type = nil + end + + if attributes.key?(:'rounding_value') + self.rounding_value = attributes[:'rounding_value'] + else + self.rounding_value = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @period_type.nil? + invalid_properties.push('invalid value for "period_type", period_type cannot be nil.') + end + + if @period_value.nil? + invalid_properties.push('invalid value for "period_value", period_value cannot be nil.') + end + + if @rounding_type.nil? + invalid_properties.push('invalid value for "rounding_type", rounding_type cannot be nil.') + end + + if @rounding_value.nil? + invalid_properties.push('invalid value for "rounding_value", rounding_value cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @period_type.nil? + return false if @period_value.nil? + return false if @rounding_type.nil? + return false if @rounding_value.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + period_type == o.period_type && + period_value == o.period_value && + rounding_type == o.rounding_type && + rounding_value == o.rounding_value + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [period_type, period_value, rounding_type, rounding_value].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_loyalty_voucher.rb b/lib/VoucherifySdk/models/campaign_loyalty_voucher.rb new file mode 100644 index 00000000..5a3933fb --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_loyalty_voucher.rb @@ -0,0 +1,291 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema model for a discount voucher. + class CampaignLoyaltyVoucher + # Type of voucher. + attr_accessor :type + + attr_accessor :loyalty_card + + attr_accessor :redemption + + attr_accessor :code_config + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'loyalty_card' => :'loyalty_card', + :'redemption' => :'redemption', + :'code_config' => :'code_config' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'loyalty_card' => :'CampaignLoyaltyCard', + :'redemption' => :'CampaignLoyaltyVoucherRedemption', + :'code_config' => :'CodeConfig' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignLoyaltyVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignLoyaltyVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'LOYALTY_CARD' + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + else + self.loyalty_card = nil + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'code_config') + self.code_config = attributes[:'code_config'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @loyalty_card.nil? + invalid_properties.push('invalid value for "loyalty_card", loyalty_card cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + return false if @loyalty_card.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + loyalty_card == o.loyalty_card && + redemption == o.redemption && + code_config == o.code_config + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, loyalty_card, redemption, code_config].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_loyalty_voucher_redemption.rb b/lib/VoucherifySdk/models/campaign_loyalty_voucher_redemption.rb new file mode 100644 index 00000000..f7175ddd --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_loyalty_voucher_redemption.rb @@ -0,0 +1,217 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the redemption limits on vouchers. + class CampaignLoyaltyVoucherRedemption + # How many times a voucher can be redeemed. A `null` value means unlimited. + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'quantity' => :'quantity' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'quantity' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'quantity' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignLoyaltyVoucherRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignLoyaltyVoucherRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + quantity == o.quantity + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [quantity].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_voucher.rb b/lib/VoucherifySdk/models/campaign_voucher.rb new file mode 100644 index 00000000..dbe1bc2f --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_voucher.rb @@ -0,0 +1,328 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema model for a campaign voucher. + class CampaignVoucher + # Type of voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + attr_accessor :redemption + + attr_accessor :code_config + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'redemption' => :'redemption', + :'code_config' => :'code_config', + :'is_referral_code' => :'is_referral_code', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'discount' => :'Discount', + :'gift' => :'Gift', + :'loyalty_card' => :'CampaignLoyaltyCard', + :'redemption' => :'CampaignVoucherRedemption', + :'code_config' => :'CodeConfigRequiredLengthCharsetPattern', + :'is_referral_code' => :'Boolean', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'DISCOUNT_VOUCHER' + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + else + self.redemption = nil + end + + if attributes.key?(:'code_config') + self.code_config = attributes[:'code_config'] + else + self.code_config = nil + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + else + self.is_referral_code = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @redemption.nil? + invalid_properties.push('invalid value for "redemption", redemption cannot be nil.') + end + + if @code_config.nil? + invalid_properties.push('invalid value for "code_config", code_config cannot be nil.') + end + + if @is_referral_code.nil? + invalid_properties.push('invalid value for "is_referral_code", is_referral_code cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + return false if @redemption.nil? + return false if @code_config.nil? + return false if @is_referral_code.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + redemption == o.redemption && + code_config == o.code_config && + is_referral_code == o.is_referral_code && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, discount, gift, loyalty_card, redemption, code_config, is_referral_code, start_date, expiration_date, validity_timeframe].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaign_voucher_redemption.rb b/lib/VoucherifySdk/models/campaign_voucher_redemption.rb new file mode 100644 index 00000000..2e39f387 --- /dev/null +++ b/lib/VoucherifySdk/models/campaign_voucher_redemption.rb @@ -0,0 +1,219 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the redemption limits on vouchers. + class CampaignVoucherRedemption + # How many times a voucher can be redeemed. A `null` value means unlimited. + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'quantity' => :'quantity' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'quantity' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'quantity' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignVoucherRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignVoucherRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + quantity == o.quantity + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [quantity].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_base.rb b/lib/VoucherifySdk/models/campaigns_create_base.rb new file mode 100644 index 00000000..165d98f0 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_base.rb @@ -0,0 +1,422 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Base body schema for creating a campaign using **POST** `/campaigns`. + class CampaignsCreateBase + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + # Total number of unique vouchers in campaign (size of campaign). + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'type' => :'type', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'validation_rules' => :'validation_rules', + :'category_id' => :'category_id', + :'category' => :'category', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'type' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'validation_rules' => :'Array', + :'category_id' => :'String', + :'category' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreateBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreateBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@validation_rules.nil? && @validation_rules.length > 1 + invalid_properties.push('invalid value for "validation_rules", number of items must be less than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if !@validation_rules.nil? && @validation_rules.length > 1 + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] validation_rules Value to be assigned + def validation_rules=(validation_rules) + if validation_rules.nil? + fail ArgumentError, 'validation_rules cannot be nil' + end + + if validation_rules.length > 1 + fail ArgumentError, 'invalid value for "validation_rules", number of items must be less than or equal to 1.' + end + + @validation_rules = validation_rules + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + type == o.type && + join_once == o.join_once && + auto_join == o.auto_join && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + validation_rules == o.validation_rules && + category_id == o.category_id && + category == o.category && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, type, join_once, auto_join, use_voucher_metadata_schema, vouchers_count, start_date, expiration_date, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, validation_rules, category_id, category, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_discount_coupons_campaign.rb b/lib/VoucherifySdk/models/campaigns_create_discount_coupons_campaign.rb new file mode 100644 index 00000000..fd98a0a1 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_discount_coupons_campaign.rb @@ -0,0 +1,461 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsCreateDiscountCouponsCampaign + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + # Total number of unique vouchers in campaign (size of campaign). + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Type of campaign. + attr_accessor :campaign_type + + attr_accessor :voucher + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'type' => :'type', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'validation_rules' => :'validation_rules', + :'category_id' => :'category_id', + :'category' => :'category', + :'metadata' => :'metadata', + :'campaign_type' => :'campaign_type', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'type' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'validation_rules' => :'Array', + :'category_id' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'campaign_type' => :'String', + :'voucher' => :'DiscountCouponsCampaignVoucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsCreateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreateDiscountCouponsCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreateDiscountCouponsCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = 'DISCOUNT_COUPONS' + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@validation_rules.nil? && @validation_rules.length > 1 + invalid_properties.push('invalid value for "validation_rules", number of items must be less than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if !@validation_rules.nil? && @validation_rules.length > 1 + campaign_type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_COUPONS"]) + return false unless campaign_type_validator.valid?(@campaign_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] validation_rules Value to be assigned + def validation_rules=(validation_rules) + if validation_rules.nil? + fail ArgumentError, 'validation_rules cannot be nil' + end + + if validation_rules.length > 1 + fail ArgumentError, 'invalid value for "validation_rules", number of items must be less than or equal to 1.' + end + + @validation_rules = validation_rules + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["DISCOUNT_COUPONS"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + type == o.type && + join_once == o.join_once && + auto_join == o.auto_join && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + validation_rules == o.validation_rules && + category_id == o.category_id && + category == o.category && + metadata == o.metadata && + campaign_type == o.campaign_type && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, type, join_once, auto_join, use_voucher_metadata_schema, vouchers_count, start_date, expiration_date, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, validation_rules, category_id, category, metadata, campaign_type, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_gift_campaign.rb b/lib/VoucherifySdk/models/campaigns_create_gift_campaign.rb new file mode 100644 index 00000000..08aec94b --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_gift_campaign.rb @@ -0,0 +1,461 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsCreateGiftCampaign + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + # Total number of unique vouchers in campaign (size of campaign). + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Type of campaign. + attr_accessor :campaign_type + + attr_accessor :voucher + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'type' => :'type', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'validation_rules' => :'validation_rules', + :'category_id' => :'category_id', + :'category' => :'category', + :'metadata' => :'metadata', + :'campaign_type' => :'campaign_type', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'type' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'validation_rules' => :'Array', + :'category_id' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'campaign_type' => :'String', + :'voucher' => :'GiftCampaignVoucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsCreateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreateGiftCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreateGiftCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = 'GIFT_VOUCHERS' + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@validation_rules.nil? && @validation_rules.length > 1 + invalid_properties.push('invalid value for "validation_rules", number of items must be less than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if !@validation_rules.nil? && @validation_rules.length > 1 + campaign_type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHERS"]) + return false unless campaign_type_validator.valid?(@campaign_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] validation_rules Value to be assigned + def validation_rules=(validation_rules) + if validation_rules.nil? + fail ArgumentError, 'validation_rules cannot be nil' + end + + if validation_rules.length > 1 + fail ArgumentError, 'invalid value for "validation_rules", number of items must be less than or equal to 1.' + end + + @validation_rules = validation_rules + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHERS"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + type == o.type && + join_once == o.join_once && + auto_join == o.auto_join && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + validation_rules == o.validation_rules && + category_id == o.category_id && + category == o.category && + metadata == o.metadata && + campaign_type == o.campaign_type && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, type, join_once, auto_join, use_voucher_metadata_schema, vouchers_count, start_date, expiration_date, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, validation_rules, category_id, category, metadata, campaign_type, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_giveaway_campaign.rb b/lib/VoucherifySdk/models/campaigns_create_giveaway_campaign.rb new file mode 100644 index 00000000..8ebefb5e --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_giveaway_campaign.rb @@ -0,0 +1,470 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsCreateGiveawayCampaign + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + # Total number of unique vouchers in campaign (size of campaign). + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Type of campaign. + attr_accessor :campaign_type + + attr_accessor :voucher + + attr_accessor :lucky_draw + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'type' => :'type', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'validation_rules' => :'validation_rules', + :'category_id' => :'category_id', + :'category' => :'category', + :'metadata' => :'metadata', + :'campaign_type' => :'campaign_type', + :'voucher' => :'voucher', + :'lucky_draw' => :'lucky_draw' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'type' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'validation_rules' => :'Array', + :'category_id' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'campaign_type' => :'String', + :'voucher' => :'GiveawayCampaignVoucher', + :'lucky_draw' => :'LuckyDraw' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsCreateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreateGiveawayCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreateGiveawayCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = 'LUCKY_DRAW' + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'lucky_draw') + self.lucky_draw = attributes[:'lucky_draw'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@validation_rules.nil? && @validation_rules.length > 1 + invalid_properties.push('invalid value for "validation_rules", number of items must be less than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if !@validation_rules.nil? && @validation_rules.length > 1 + campaign_type_validator = EnumAttributeValidator.new('String', ["LUCKY_DRAW"]) + return false unless campaign_type_validator.valid?(@campaign_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] validation_rules Value to be assigned + def validation_rules=(validation_rules) + if validation_rules.nil? + fail ArgumentError, 'validation_rules cannot be nil' + end + + if validation_rules.length > 1 + fail ArgumentError, 'invalid value for "validation_rules", number of items must be less than or equal to 1.' + end + + @validation_rules = validation_rules + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["LUCKY_DRAW"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + type == o.type && + join_once == o.join_once && + auto_join == o.auto_join && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + validation_rules == o.validation_rules && + category_id == o.category_id && + category == o.category && + metadata == o.metadata && + campaign_type == o.campaign_type && + voucher == o.voucher && + lucky_draw == o.lucky_draw + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, type, join_once, auto_join, use_voucher_metadata_schema, vouchers_count, start_date, expiration_date, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, validation_rules, category_id, category, metadata, campaign_type, voucher, lucky_draw].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_loyalty_campaign.rb b/lib/VoucherifySdk/models/campaigns_create_loyalty_campaign.rb new file mode 100644 index 00000000..583dbf1b --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_loyalty_campaign.rb @@ -0,0 +1,461 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsCreateLoyaltyCampaign + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + # Total number of unique vouchers in campaign (size of campaign). + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Type of campaign. + attr_accessor :campaign_type + + attr_accessor :voucher + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'type' => :'type', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'validation_rules' => :'validation_rules', + :'category_id' => :'category_id', + :'category' => :'category', + :'metadata' => :'metadata', + :'campaign_type' => :'campaign_type', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'type' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'validation_rules' => :'Array', + :'category_id' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'campaign_type' => :'String', + :'voucher' => :'CampaignLoyaltyVoucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsCreateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreateLoyaltyCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreateLoyaltyCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = 'LOYALTY_PROGRAM' + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@validation_rules.nil? && @validation_rules.length > 1 + invalid_properties.push('invalid value for "validation_rules", number of items must be less than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if !@validation_rules.nil? && @validation_rules.length > 1 + campaign_type_validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM"]) + return false unless campaign_type_validator.valid?(@campaign_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] validation_rules Value to be assigned + def validation_rules=(validation_rules) + if validation_rules.nil? + fail ArgumentError, 'validation_rules cannot be nil' + end + + if validation_rules.length > 1 + fail ArgumentError, 'invalid value for "validation_rules", number of items must be less than or equal to 1.' + end + + @validation_rules = validation_rules + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + type == o.type && + join_once == o.join_once && + auto_join == o.auto_join && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + validation_rules == o.validation_rules && + category_id == o.category_id && + category == o.category && + metadata == o.metadata && + campaign_type == o.campaign_type && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, type, join_once, auto_join, use_voucher_metadata_schema, vouchers_count, start_date, expiration_date, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, validation_rules, category_id, category, metadata, campaign_type, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_promotion_campaign.rb b/lib/VoucherifySdk/models/campaigns_create_promotion_campaign.rb new file mode 100644 index 00000000..973890ed --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_promotion_campaign.rb @@ -0,0 +1,461 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsCreatePromotionCampaign + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + # Total number of unique vouchers in campaign (size of campaign). + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Type of campaign. + attr_accessor :campaign_type + + attr_accessor :promotion + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'type' => :'type', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'validation_rules' => :'validation_rules', + :'category_id' => :'category_id', + :'category' => :'category', + :'metadata' => :'metadata', + :'campaign_type' => :'campaign_type', + :'promotion' => :'promotion' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'type' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'validation_rules' => :'Array', + :'category_id' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'campaign_type' => :'String', + :'promotion' => :'SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsCreateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreatePromotionCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreatePromotionCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = 'PROMOTION' + end + + if attributes.key?(:'promotion') + self.promotion = attributes[:'promotion'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@validation_rules.nil? && @validation_rules.length > 1 + invalid_properties.push('invalid value for "validation_rules", number of items must be less than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if !@validation_rules.nil? && @validation_rules.length > 1 + campaign_type_validator = EnumAttributeValidator.new('String', ["PROMOTION"]) + return false unless campaign_type_validator.valid?(@campaign_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] validation_rules Value to be assigned + def validation_rules=(validation_rules) + if validation_rules.nil? + fail ArgumentError, 'validation_rules cannot be nil' + end + + if validation_rules.length > 1 + fail ArgumentError, 'invalid value for "validation_rules", number of items must be less than or equal to 1.' + end + + @validation_rules = validation_rules + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["PROMOTION"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + type == o.type && + join_once == o.join_once && + auto_join == o.auto_join && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + validation_rules == o.validation_rules && + category_id == o.category_id && + category == o.category && + metadata == o.metadata && + campaign_type == o.campaign_type && + promotion == o.promotion + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, type, join_once, auto_join, use_voucher_metadata_schema, vouchers_count, start_date, expiration_date, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, validation_rules, category_id, category, metadata, campaign_type, promotion].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_referral_campaign.rb b/lib/VoucherifySdk/models/campaigns_create_referral_campaign.rb new file mode 100644 index 00000000..68186070 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_referral_campaign.rb @@ -0,0 +1,470 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsCreateReferralCampaign + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + # Total number of unique vouchers in campaign (size of campaign). + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Type of campaign. + attr_accessor :campaign_type + + attr_accessor :referral_program + + attr_accessor :voucher + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'type' => :'type', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'validation_rules' => :'validation_rules', + :'category_id' => :'category_id', + :'category' => :'category', + :'metadata' => :'metadata', + :'campaign_type' => :'campaign_type', + :'referral_program' => :'referral_program', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'type' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'validation_rules' => :'Array', + :'category_id' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'campaign_type' => :'String', + :'referral_program' => :'ReferralProgram', + :'voucher' => :'ReferralCampaignVoucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsCreateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreateReferralCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreateReferralCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = 'REFERRAL_PROGRAM' + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@validation_rules.nil? && @validation_rules.length > 1 + invalid_properties.push('invalid value for "validation_rules", number of items must be less than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if !@validation_rules.nil? && @validation_rules.length > 1 + campaign_type_validator = EnumAttributeValidator.new('String', ["REFERRAL_PROGRAM"]) + return false unless campaign_type_validator.valid?(@campaign_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] validation_rules Value to be assigned + def validation_rules=(validation_rules) + if validation_rules.nil? + fail ArgumentError, 'validation_rules cannot be nil' + end + + if validation_rules.length > 1 + fail ArgumentError, 'invalid value for "validation_rules", number of items must be less than or equal to 1.' + end + + @validation_rules = validation_rules + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["REFERRAL_PROGRAM"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + type == o.type && + join_once == o.join_once && + auto_join == o.auto_join && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + validation_rules == o.validation_rules && + category_id == o.category_id && + category == o.category && + metadata == o.metadata && + campaign_type == o.campaign_type && + referral_program == o.referral_program && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, type, join_once, auto_join, use_voucher_metadata_schema, vouchers_count, start_date, expiration_date, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, validation_rules, category_id, category, metadata, campaign_type, referral_program, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_request_body.rb b/lib/VoucherifySdk/models/campaigns_create_request_body.rb new file mode 100644 index 00000000..7a007fdf --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_request_body.rb @@ -0,0 +1,110 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/campaigns`. + module CampaignsCreateRequestBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'CampaignsCreateDiscountCouponsCampaign', + :'CampaignsCreateGiftCampaign', + :'CampaignsCreateGiveawayCampaign', + :'CampaignsCreateLoyaltyCampaign', + :'CampaignsCreatePromotionCampaign', + :'CampaignsCreateReferralCampaign' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_create_response_body.rb b/lib/VoucherifySdk/models/campaigns_create_response_body.rb new file mode 100644 index 00000000..11bc9fdf --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_create_response_body.rb @@ -0,0 +1,675 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/campaigns/{campaignId}`. + class CampaignsCreateResponseBody + # Unique campaign ID, assigned by Voucherify. + attr_accessor :id + + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Type of campaign. + attr_accessor :campaign_type + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published + attr_accessor :type + + attr_accessor :voucher + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Total number of unique vouchers in campaign. + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + # A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign + attr_accessor :active + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the campaign was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique category name. + attr_accessor :category + + # Indicates the status of the campaign creation. + attr_accessor :creation_status + + # Indicates the status of the campaign's vouchers. + attr_accessor :vouchers_generation_status + + # Indicates whether the resource can be deleted. + attr_accessor :protected + + # Unique category ID that this campaign belongs to. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # The type of object represented by JSON. This object stores information about the campaign. + attr_accessor :object + + attr_accessor :referral_program + + attr_accessor :loyalty_tiers_expiration + + attr_accessor :promotion + + attr_accessor :validation_rules_assignments + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'campaign_type' => :'campaign_type', + :'type' => :'type', + :'voucher' => :'voucher', + :'auto_join' => :'auto_join', + :'join_once' => :'join_once', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'active' => :'active', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'category' => :'category', + :'creation_status' => :'creation_status', + :'vouchers_generation_status' => :'vouchers_generation_status', + :'protected' => :'protected', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'object' => :'object', + :'referral_program' => :'referral_program', + :'loyalty_tiers_expiration' => :'loyalty_tiers_expiration', + :'promotion' => :'promotion', + :'validation_rules_assignments' => :'validation_rules_assignments' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'campaign_type' => :'String', + :'type' => :'String', + :'voucher' => :'CampaignVoucher', + :'auto_join' => :'Boolean', + :'join_once' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'active' => :'Boolean', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'category' => :'String', + :'creation_status' => :'String', + :'vouchers_generation_status' => :'String', + :'protected' => :'Boolean', + :'category_id' => :'String', + :'categories' => :'Array', + :'object' => :'String', + :'referral_program' => :'ReferralProgram', + :'loyalty_tiers_expiration' => :'LoyaltyTiersExpirationAll', + :'promotion' => :'PromotionTiersList', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Campaign' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + else + self.auto_join = nil + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + else + self.join_once = nil + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + else + self.use_voucher_metadata_schema = nil + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'creation_status') + self.creation_status = attributes[:'creation_status'] + else + self.creation_status = nil + end + + if attributes.key?(:'vouchers_generation_status') + self.vouchers_generation_status = attributes[:'vouchers_generation_status'] + else + self.vouchers_generation_status = nil + end + + if attributes.key?(:'protected') + self.protected = attributes[:'protected'] + else + self.protected = nil + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'campaign' + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + + if attributes.key?(:'loyalty_tiers_expiration') + self.loyalty_tiers_expiration = attributes[:'loyalty_tiers_expiration'] + end + + if attributes.key?(:'promotion') + self.promotion = attributes[:'promotion'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @campaign_type.nil? + invalid_properties.push('invalid value for "campaign_type", campaign_type cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @auto_join.nil? + invalid_properties.push('invalid value for "auto_join", auto_join cannot be nil.') + end + + if @join_once.nil? + invalid_properties.push('invalid value for "join_once", join_once cannot be nil.') + end + + if @use_voucher_metadata_schema.nil? + invalid_properties.push('invalid value for "use_voucher_metadata_schema", use_voucher_metadata_schema cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @creation_status.nil? + invalid_properties.push('invalid value for "creation_status", creation_status cannot be nil.') + end + + if @vouchers_generation_status.nil? + invalid_properties.push('invalid value for "vouchers_generation_status", vouchers_generation_status cannot be nil.') + end + + if @protected.nil? + invalid_properties.push('invalid value for "protected", protected cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @campaign_type.nil? + campaign_type_validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + return false unless campaign_type_validator.valid?(@campaign_type) + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if @auto_join.nil? + return false if @join_once.nil? + return false if @use_voucher_metadata_schema.nil? + return false if @created_at.nil? + return false if @creation_status.nil? + creation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless creation_status_validator.valid?(@creation_status) + return false if @vouchers_generation_status.nil? + vouchers_generation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless vouchers_generation_status_validator.valid?(@vouchers_generation_status) + return false if @protected.nil? + return false if @categories.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] creation_status Object to be assigned + def creation_status=(creation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(creation_status) + fail ArgumentError, "invalid value for \"creation_status\", must be one of #{validator.allowable_values}." + end + @creation_status = creation_status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] vouchers_generation_status Object to be assigned + def vouchers_generation_status=(vouchers_generation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(vouchers_generation_status) + fail ArgumentError, "invalid value for \"vouchers_generation_status\", must be one of #{validator.allowable_values}." + end + @vouchers_generation_status = vouchers_generation_status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + description == o.description && + campaign_type == o.campaign_type && + type == o.type && + voucher == o.voucher && + auto_join == o.auto_join && + join_once == o.join_once && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + active == o.active && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + category == o.category && + creation_status == o.creation_status && + vouchers_generation_status == o.vouchers_generation_status && + protected == o.protected && + category_id == o.category_id && + categories == o.categories && + object == o.object && + referral_program == o.referral_program && + loyalty_tiers_expiration == o.loyalty_tiers_expiration && + promotion == o.promotion && + validation_rules_assignments == o.validation_rules_assignments + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, description, campaign_type, type, voucher, auto_join, join_once, use_voucher_metadata_schema, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, vouchers_count, start_date, expiration_date, active, metadata, created_at, updated_at, category, creation_status, vouchers_generation_status, protected, category_id, categories, object, referral_program, loyalty_tiers_expiration, promotion, validation_rules_assignments].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_delete_response_body.rb b/lib/VoucherifySdk/models/campaigns_delete_response_body.rb new file mode 100644 index 00000000..cfc9158f --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_delete_response_body.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **DELETE** `/campaigns/{campaignId}`. + class CampaignsDeleteResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsDeleteResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsDeleteResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_disable_response_body.rb b/lib/VoucherifySdk/models/campaigns_disable_response_body.rb new file mode 100644 index 00000000..c03aa28e --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_disable_response_body.rb @@ -0,0 +1,206 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/campaigns/{campaignId}/disable`. + class CampaignsDisableResponseBody + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsDisableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsDisableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_enable_response_body.rb b/lib/VoucherifySdk/models/campaigns_enable_response_body.rb new file mode 100644 index 00000000..81262290 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_enable_response_body.rb @@ -0,0 +1,206 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/campaigns/{campaignId}/enable`. + class CampaignsEnableResponseBody + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsEnableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsEnableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_get_response_body.rb b/lib/VoucherifySdk/models/campaigns_get_response_body.rb new file mode 100644 index 00000000..1bfdef13 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_get_response_body.rb @@ -0,0 +1,675 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/campaigns/{campaignId}`. + class CampaignsGetResponseBody + # Unique campaign ID, assigned by Voucherify. + attr_accessor :id + + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Type of campaign. + attr_accessor :campaign_type + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published + attr_accessor :type + + attr_accessor :voucher + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Total number of unique vouchers in campaign. + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + # A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign + attr_accessor :active + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the campaign was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique category name. + attr_accessor :category + + # Indicates the status of the campaign creation. + attr_accessor :creation_status + + # Indicates the status of the campaign's vouchers. + attr_accessor :vouchers_generation_status + + # Indicates whether the resource can be deleted. + attr_accessor :protected + + # Unique category ID that this campaign belongs to. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # The type of object represented by JSON. This object stores information about the campaign. + attr_accessor :object + + attr_accessor :referral_program + + attr_accessor :loyalty_tiers_expiration + + attr_accessor :promotion + + attr_accessor :validation_rules_assignments + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'campaign_type' => :'campaign_type', + :'type' => :'type', + :'voucher' => :'voucher', + :'auto_join' => :'auto_join', + :'join_once' => :'join_once', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'active' => :'active', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'category' => :'category', + :'creation_status' => :'creation_status', + :'vouchers_generation_status' => :'vouchers_generation_status', + :'protected' => :'protected', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'object' => :'object', + :'referral_program' => :'referral_program', + :'loyalty_tiers_expiration' => :'loyalty_tiers_expiration', + :'promotion' => :'promotion', + :'validation_rules_assignments' => :'validation_rules_assignments' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'campaign_type' => :'String', + :'type' => :'String', + :'voucher' => :'CampaignVoucher', + :'auto_join' => :'Boolean', + :'join_once' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'active' => :'Boolean', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'category' => :'String', + :'creation_status' => :'String', + :'vouchers_generation_status' => :'String', + :'protected' => :'Boolean', + :'category_id' => :'String', + :'categories' => :'Array', + :'object' => :'String', + :'referral_program' => :'ReferralProgram', + :'loyalty_tiers_expiration' => :'LoyaltyTiersExpirationAll', + :'promotion' => :'PromotionTiersList', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Campaign' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + else + self.auto_join = nil + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + else + self.join_once = nil + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + else + self.use_voucher_metadata_schema = nil + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'creation_status') + self.creation_status = attributes[:'creation_status'] + else + self.creation_status = nil + end + + if attributes.key?(:'vouchers_generation_status') + self.vouchers_generation_status = attributes[:'vouchers_generation_status'] + else + self.vouchers_generation_status = nil + end + + if attributes.key?(:'protected') + self.protected = attributes[:'protected'] + else + self.protected = nil + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'campaign' + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + + if attributes.key?(:'loyalty_tiers_expiration') + self.loyalty_tiers_expiration = attributes[:'loyalty_tiers_expiration'] + end + + if attributes.key?(:'promotion') + self.promotion = attributes[:'promotion'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @campaign_type.nil? + invalid_properties.push('invalid value for "campaign_type", campaign_type cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @auto_join.nil? + invalid_properties.push('invalid value for "auto_join", auto_join cannot be nil.') + end + + if @join_once.nil? + invalid_properties.push('invalid value for "join_once", join_once cannot be nil.') + end + + if @use_voucher_metadata_schema.nil? + invalid_properties.push('invalid value for "use_voucher_metadata_schema", use_voucher_metadata_schema cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @creation_status.nil? + invalid_properties.push('invalid value for "creation_status", creation_status cannot be nil.') + end + + if @vouchers_generation_status.nil? + invalid_properties.push('invalid value for "vouchers_generation_status", vouchers_generation_status cannot be nil.') + end + + if @protected.nil? + invalid_properties.push('invalid value for "protected", protected cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @campaign_type.nil? + campaign_type_validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + return false unless campaign_type_validator.valid?(@campaign_type) + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if @auto_join.nil? + return false if @join_once.nil? + return false if @use_voucher_metadata_schema.nil? + return false if @created_at.nil? + return false if @creation_status.nil? + creation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless creation_status_validator.valid?(@creation_status) + return false if @vouchers_generation_status.nil? + vouchers_generation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless vouchers_generation_status_validator.valid?(@vouchers_generation_status) + return false if @protected.nil? + return false if @categories.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] creation_status Object to be assigned + def creation_status=(creation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(creation_status) + fail ArgumentError, "invalid value for \"creation_status\", must be one of #{validator.allowable_values}." + end + @creation_status = creation_status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] vouchers_generation_status Object to be assigned + def vouchers_generation_status=(vouchers_generation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(vouchers_generation_status) + fail ArgumentError, "invalid value for \"vouchers_generation_status\", must be one of #{validator.allowable_values}." + end + @vouchers_generation_status = vouchers_generation_status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + description == o.description && + campaign_type == o.campaign_type && + type == o.type && + voucher == o.voucher && + auto_join == o.auto_join && + join_once == o.join_once && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + active == o.active && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + category == o.category && + creation_status == o.creation_status && + vouchers_generation_status == o.vouchers_generation_status && + protected == o.protected && + category_id == o.category_id && + categories == o.categories && + object == o.object && + referral_program == o.referral_program && + loyalty_tiers_expiration == o.loyalty_tiers_expiration && + promotion == o.promotion && + validation_rules_assignments == o.validation_rules_assignments + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, description, campaign_type, type, voucher, auto_join, join_once, use_voucher_metadata_schema, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, vouchers_count, start_date, expiration_date, active, metadata, created_at, updated_at, category, creation_status, vouchers_generation_status, protected, category_id, categories, object, referral_program, loyalty_tiers_expiration, promotion, validation_rules_assignments].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_import_create_response_body.rb b/lib/VoucherifySdk/models/campaigns_import_create_response_body.rb new file mode 100644 index 00000000..182ed6ee --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_import_create_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/campaigns/{campaignId}/import`. + class CampaignsImportCreateResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsImportCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsImportCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_import_csv_create_response_body.rb b/lib/VoucherifySdk/models/campaigns_import_csv_create_response_body.rb new file mode 100644 index 00000000..c254ec02 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_import_csv_create_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/campaigns/{campaignId}/importCSV`. + class CampaignsImportCsvCreateResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsImportCsvCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsImportCsvCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_import_voucher_item.rb b/lib/VoucherifySdk/models/campaigns_import_voucher_item.rb new file mode 100644 index 00000000..802d108a --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_import_voucher_item.rb @@ -0,0 +1,374 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Import Vouchers to Campaign + class CampaignsImportVoucherItem + # Unique custom voucher code. + attr_accessor :code + + # Type of voucher. + attr_accessor :type + + attr_accessor :redemption + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher + attr_accessor :active + + # The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'type' => :'type', + :'redemption' => :'redemption', + :'active' => :'active', + :'metadata' => :'metadata', + :'category' => :'category', + :'start_date' => :'start_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'additional_info' => :'additional_info', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'String', + :'type' => :'String', + :'redemption' => :'CampaignsImportVoucherItemRedemption', + :'active' => :'Boolean', + :'metadata' => :'Object', + :'category' => :'String', + :'start_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'additional_info' => :'String', + :'discount' => :'Discount', + :'gift' => :'Gift', + :'loyalty_card' => :'CampaignsImportVoucherLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsImportVoucherItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsImportVoucherItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER", "GIFT_VOUCHER", "LOYALTY_CARD", "LUCKY_DRAW_CODE"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER", "GIFT_VOUCHER", "LOYALTY_CARD", "LUCKY_DRAW_CODE"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code && + type == o.type && + redemption == o.redemption && + active == o.active && + metadata == o.metadata && + category == o.category && + start_date == o.start_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + additional_info == o.additional_info && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [code, type, redemption, active, metadata, category, start_date, validity_timeframe, validity_day_of_week, additional_info, discount, gift, loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_import_voucher_item_redemption.rb b/lib/VoucherifySdk/models/campaigns_import_voucher_item_redemption.rb new file mode 100644 index 00000000..a2f34887 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_import_voucher_item_redemption.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores the quantity of redemptions that can be applied to the voucher. + class CampaignsImportVoucherItemRedemption + # How many times a voucher can be redeemed. A `null` value means unlimited. + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'quantity' => :'quantity' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'quantity' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsImportVoucherItemRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsImportVoucherItemRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + quantity == o.quantity + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [quantity].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_import_voucher_loyalty_card.rb b/lib/VoucherifySdk/models/campaigns_import_voucher_loyalty_card.rb new file mode 100644 index 00000000..91326e35 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_import_voucher_loyalty_card.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema model for a campaign loyalty card. + class CampaignsImportVoucherLoyaltyCard + # The initial number of points to assign to the loyalty card. This is the current loyalty card score i.e. the number of loyalty points on the card. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsImportVoucherLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsImportVoucherLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_list_response_body.rb b/lib/VoucherifySdk/models/campaigns_list_response_body.rb new file mode 100644 index 00000000..c6fac9d3 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_list_response_body.rb @@ -0,0 +1,252 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema model for **GET** `/campaigns`. + class CampaignsListResponseBody + # The type of object represented by JSON. This object stores information about campaigns in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of campaign objects. + attr_accessor :data_ref + + # Contains array of campaign objects. + attr_accessor :campaigns + + # Total number of campaigns. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'campaigns' => :'campaigns', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'campaigns' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'campaigns' + end + + if attributes.key?(:'campaigns') + if (value = attributes[:'campaigns']).is_a?(Array) + self.campaigns = value + end + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + campaigns == o.campaigns && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, campaigns, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_base.rb b/lib/VoucherifySdk/models/campaigns_update_base.rb new file mode 100644 index 00000000..f2cac97f --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_base.rb @@ -0,0 +1,300 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Base body schema for creating a campaign using **PUT** `/campaigns`. + class CampaignsUpdateBase + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_coupon_campaign_base.rb b/lib/VoucherifySdk/models/campaigns_update_coupon_campaign_base.rb new file mode 100644 index 00000000..045a3b57 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_coupon_campaign_base.rb @@ -0,0 +1,381 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Base body schema for updating a campaign which contains coupon codes using **PUT** `/campaigns`. + class CampaignsUpdateCouponCampaignBase + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String', + :'activity_duration_after_publishing' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsUpdateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateCouponCampaignBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateCouponCampaignBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id && + activity_duration_after_publishing == o.activity_duration_after_publishing && + join_once == o.join_once && + auto_join == o.auto_join && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id, activity_duration_after_publishing, join_once, auto_join, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_discount_coupons_campaign.rb b/lib/VoucherifySdk/models/campaigns_update_discount_coupons_campaign.rb new file mode 100644 index 00000000..a8d30337 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_discount_coupons_campaign.rb @@ -0,0 +1,389 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsUpdateDiscountCouponsCampaign + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + attr_accessor :discount + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'type' => :'type', + :'discount' => :'discount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String', + :'activity_duration_after_publishing' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'type' => :'String', + :'discount' => :'Discount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsUpdateCouponCampaignBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateDiscountCouponsCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateDiscountCouponsCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id && + activity_duration_after_publishing == o.activity_duration_after_publishing && + join_once == o.join_once && + auto_join == o.auto_join && + type == o.type && + discount == o.discount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id, activity_duration_after_publishing, join_once, auto_join, type, discount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_gift_campaign.rb b/lib/VoucherifySdk/models/campaigns_update_gift_campaign.rb new file mode 100644 index 00000000..b2f7918c --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_gift_campaign.rb @@ -0,0 +1,389 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsUpdateGiftCampaign + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + attr_accessor :gift + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'type' => :'type', + :'gift' => :'gift' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String', + :'activity_duration_after_publishing' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'type' => :'String', + :'gift' => :'Gift' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsUpdateCouponCampaignBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateGiftCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateGiftCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id && + activity_duration_after_publishing == o.activity_duration_after_publishing && + join_once == o.join_once && + auto_join == o.auto_join && + type == o.type && + gift == o.gift + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id, activity_duration_after_publishing, join_once, auto_join, type, gift].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_giveaway_campaign.rb b/lib/VoucherifySdk/models/campaigns_update_giveaway_campaign.rb new file mode 100644 index 00000000..d63c2f63 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_giveaway_campaign.rb @@ -0,0 +1,420 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsUpdateGiveawayCampaign + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # It represents the total number of winners in a lucky draw. + attr_accessor :winners_count + + # It indicates whether each winner in a draw is unique or not. + attr_accessor :unique_winners_per_draw + + # Specifies whether each participant can win only once across multiple draws. + attr_accessor :unique_winners + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'type' => :'type', + :'winners_count' => :'winners_count', + :'unique_winners_per_draw' => :'unique_winners_per_draw', + :'unique_winners' => :'unique_winners' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String', + :'activity_duration_after_publishing' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'type' => :'String', + :'winners_count' => :'String', + :'unique_winners_per_draw' => :'String', + :'unique_winners' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsUpdateCouponCampaignBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateGiveawayCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateGiveawayCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'winners_count') + self.winners_count = attributes[:'winners_count'] + end + + if attributes.key?(:'unique_winners_per_draw') + self.unique_winners_per_draw = attributes[:'unique_winners_per_draw'] + end + + if attributes.key?(:'unique_winners') + self.unique_winners = attributes[:'unique_winners'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method with validation + # @param [Object] winners_count Value to be assigned + def winners_count=(winners_count) + if winners_count.nil? + fail ArgumentError, 'winners_count cannot be nil' + end + + @winners_count = winners_count + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id && + activity_duration_after_publishing == o.activity_duration_after_publishing && + join_once == o.join_once && + auto_join == o.auto_join && + type == o.type && + winners_count == o.winners_count && + unique_winners_per_draw == o.unique_winners_per_draw && + unique_winners == o.unique_winners + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id, activity_duration_after_publishing, join_once, auto_join, type, winners_count, unique_winners_per_draw, unique_winners].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_loyalty_campaign.rb b/lib/VoucherifySdk/models/campaigns_update_loyalty_campaign.rb new file mode 100644 index 00000000..eb732f6a --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_loyalty_campaign.rb @@ -0,0 +1,398 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsUpdateLoyaltyCampaign + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + attr_accessor :loyalty_tiers_expiration + + attr_accessor :options + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'type' => :'type', + :'loyalty_tiers_expiration' => :'loyalty_tiers_expiration', + :'options' => :'options' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String', + :'activity_duration_after_publishing' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'type' => :'String', + :'loyalty_tiers_expiration' => :'LoyaltyTiersExpirationAll', + :'options' => :'PropertiesForLoyaltyCampaignOptions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsUpdateCouponCampaignBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateLoyaltyCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateLoyaltyCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'loyalty_tiers_expiration') + self.loyalty_tiers_expiration = attributes[:'loyalty_tiers_expiration'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id && + activity_duration_after_publishing == o.activity_duration_after_publishing && + join_once == o.join_once && + auto_join == o.auto_join && + type == o.type && + loyalty_tiers_expiration == o.loyalty_tiers_expiration && + options == o.options + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id, activity_duration_after_publishing, join_once, auto_join, type, loyalty_tiers_expiration, options].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_promotion_campaign.rb b/lib/VoucherifySdk/models/campaigns_update_promotion_campaign.rb new file mode 100644 index 00000000..8a7f7997 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_promotion_campaign.rb @@ -0,0 +1,306 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsUpdatePromotionCampaign + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsUpdateBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdatePromotionCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdatePromotionCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_referral_campaign.rb b/lib/VoucherifySdk/models/campaigns_update_referral_campaign.rb new file mode 100644 index 00000000..98d29969 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_referral_campaign.rb @@ -0,0 +1,398 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsUpdateReferralCampaign + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Determine which metadata should be removed from campaign. + attr_accessor :unset_metadata_fields + + # Unique category ID that this campaign belongs to. Either pass this parameter OR the `category`. + attr_accessor :category_id + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :referral_program + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'description' => :'description', + :'category' => :'category', + :'metadata' => :'metadata', + :'unset_metadata_fields' => :'unset_metadata_fields', + :'category_id' => :'category_id', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'join_once' => :'join_once', + :'auto_join' => :'auto_join', + :'type' => :'type', + :'discount' => :'discount', + :'referral_program' => :'referral_program' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'description' => :'String', + :'category' => :'String', + :'metadata' => :'Object', + :'unset_metadata_fields' => :'Array', + :'category_id' => :'String', + :'activity_duration_after_publishing' => :'String', + :'join_once' => :'Boolean', + :'auto_join' => :'Boolean', + :'type' => :'String', + :'discount' => :'Discount', + :'referral_program' => :'ReferralProgram' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'unset_metadata_fields', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsUpdateCouponCampaignBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateReferralCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateReferralCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'unset_metadata_fields') + if (value = attributes[:'unset_metadata_fields']).is_a?(Array) + self.unset_metadata_fields = value + end + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + description == o.description && + category == o.category && + metadata == o.metadata && + unset_metadata_fields == o.unset_metadata_fields && + category_id == o.category_id && + activity_duration_after_publishing == o.activity_duration_after_publishing && + join_once == o.join_once && + auto_join == o.auto_join && + type == o.type && + discount == o.discount && + referral_program == o.referral_program + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [start_date, expiration_date, validity_timeframe, validity_day_of_week, description, category, metadata, unset_metadata_fields, category_id, activity_duration_after_publishing, join_once, auto_join, type, discount, referral_program].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_request_body.rb b/lib/VoucherifySdk/models/campaigns_update_request_body.rb new file mode 100644 index 00000000..2e753b6d --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_request_body.rb @@ -0,0 +1,110 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **PUT** `/campaigns/{campaignId}`. + module CampaignsUpdateRequestBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'CampaignsUpdateDiscountCouponsCampaign', + :'CampaignsUpdateGiftCampaign', + :'CampaignsUpdateGiveawayCampaign', + :'CampaignsUpdateLoyaltyCampaign', + :'CampaignsUpdatePromotionCampaign', + :'CampaignsUpdateReferralCampaign' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_update_response_body.rb b/lib/VoucherifySdk/models/campaigns_update_response_body.rb new file mode 100644 index 00000000..057eaab5 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_update_response_body.rb @@ -0,0 +1,675 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/campaigns/{campaignId}`. + class CampaignsUpdateResponseBody + # Unique campaign ID, assigned by Voucherify. + attr_accessor :id + + # Campaign name. + attr_accessor :name + + # An optional field to keep any extra textual information about the campaign such as a campaign description and details. + attr_accessor :description + + # Type of campaign. + attr_accessor :campaign_type + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: the campaign is dynamic, i.e. vouchers will generate based on set criteria - `STATIC`: vouchers need to be manually published + attr_accessor :type + + attr_accessor :voucher + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Flag indicating whether the campaign is to use the voucher's metadata schema instead of the campaign metadata schema. + attr_accessor :use_voucher_metadata_schema + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Defines the amount of time the campaign will be active in ISO 8601 format after publishing. For example, a campaign with a `duration` of `P24D` will be valid for a duration of 24 days. + attr_accessor :activity_duration_after_publishing + + # Total number of unique vouchers in campaign. + attr_accessor :vouchers_count + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + # A flag to toggle the campaign on or off. You can disable a campaign even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign + attr_accessor :active + + # The metadata object stores all custom attributes assigned to the campaign. A set of key/value pairs that you can attach to a campaign object. It can be useful for storing additional information about the campaign in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the campaign was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique category name. + attr_accessor :category + + # Indicates the status of the campaign creation. + attr_accessor :creation_status + + # Indicates the status of the campaign's vouchers. + attr_accessor :vouchers_generation_status + + # Indicates whether the resource can be deleted. + attr_accessor :protected + + # Unique category ID that this campaign belongs to. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # The type of object represented by JSON. This object stores information about the campaign. + attr_accessor :object + + attr_accessor :referral_program + + attr_accessor :loyalty_tiers_expiration + + attr_accessor :promotion + + attr_accessor :validation_rules_assignments + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'description' => :'description', + :'campaign_type' => :'campaign_type', + :'type' => :'type', + :'voucher' => :'voucher', + :'auto_join' => :'auto_join', + :'join_once' => :'join_once', + :'use_voucher_metadata_schema' => :'use_voucher_metadata_schema', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'activity_duration_after_publishing' => :'activity_duration_after_publishing', + :'vouchers_count' => :'vouchers_count', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'active' => :'active', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'category' => :'category', + :'creation_status' => :'creation_status', + :'vouchers_generation_status' => :'vouchers_generation_status', + :'protected' => :'protected', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'object' => :'object', + :'referral_program' => :'referral_program', + :'loyalty_tiers_expiration' => :'loyalty_tiers_expiration', + :'promotion' => :'promotion', + :'validation_rules_assignments' => :'validation_rules_assignments' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'campaign_type' => :'String', + :'type' => :'String', + :'voucher' => :'CampaignVoucher', + :'auto_join' => :'Boolean', + :'join_once' => :'Boolean', + :'use_voucher_metadata_schema' => :'Boolean', + :'validity_timeframe' => :'CampaignBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'activity_duration_after_publishing' => :'String', + :'vouchers_count' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'active' => :'Boolean', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'category' => :'String', + :'creation_status' => :'String', + :'vouchers_generation_status' => :'String', + :'protected' => :'Boolean', + :'category_id' => :'String', + :'categories' => :'Array', + :'object' => :'String', + :'referral_program' => :'ReferralProgram', + :'loyalty_tiers_expiration' => :'LoyaltyTiersExpirationAll', + :'promotion' => :'PromotionTiersList', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Campaign' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + else + self.campaign_type = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + else + self.auto_join = nil + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + else + self.join_once = nil + end + + if attributes.key?(:'use_voucher_metadata_schema') + self.use_voucher_metadata_schema = attributes[:'use_voucher_metadata_schema'] + else + self.use_voucher_metadata_schema = nil + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'activity_duration_after_publishing') + self.activity_duration_after_publishing = attributes[:'activity_duration_after_publishing'] + end + + if attributes.key?(:'vouchers_count') + self.vouchers_count = attributes[:'vouchers_count'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'creation_status') + self.creation_status = attributes[:'creation_status'] + else + self.creation_status = nil + end + + if attributes.key?(:'vouchers_generation_status') + self.vouchers_generation_status = attributes[:'vouchers_generation_status'] + else + self.vouchers_generation_status = nil + end + + if attributes.key?(:'protected') + self.protected = attributes[:'protected'] + else + self.protected = nil + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'campaign' + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + + if attributes.key?(:'loyalty_tiers_expiration') + self.loyalty_tiers_expiration = attributes[:'loyalty_tiers_expiration'] + end + + if attributes.key?(:'promotion') + self.promotion = attributes[:'promotion'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @campaign_type.nil? + invalid_properties.push('invalid value for "campaign_type", campaign_type cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @auto_join.nil? + invalid_properties.push('invalid value for "auto_join", auto_join cannot be nil.') + end + + if @join_once.nil? + invalid_properties.push('invalid value for "join_once", join_once cannot be nil.') + end + + if @use_voucher_metadata_schema.nil? + invalid_properties.push('invalid value for "use_voucher_metadata_schema", use_voucher_metadata_schema cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @creation_status.nil? + invalid_properties.push('invalid value for "creation_status", creation_status cannot be nil.') + end + + if @vouchers_generation_status.nil? + invalid_properties.push('invalid value for "vouchers_generation_status", vouchers_generation_status cannot be nil.') + end + + if @protected.nil? + invalid_properties.push('invalid value for "protected", protected cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @campaign_type.nil? + campaign_type_validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + return false unless campaign_type_validator.valid?(@campaign_type) + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + return false if @auto_join.nil? + return false if @join_once.nil? + return false if @use_voucher_metadata_schema.nil? + return false if @created_at.nil? + return false if @creation_status.nil? + creation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless creation_status_validator.valid?(@creation_status) + return false if @vouchers_generation_status.nil? + vouchers_generation_status_validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + return false unless vouchers_generation_status_validator.valid?(@vouchers_generation_status) + return false if @protected.nil? + return false if @categories.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] campaign_type Object to be assigned + def campaign_type=(campaign_type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_PROGRAM", "GIFT_VOUCHERS", "DISCOUNT_COUPONS", "PROMOTION", "REFERRAL_PROGRAM", "LUCKY_DRAW"]) + unless validator.valid?(campaign_type) + fail ArgumentError, "invalid value for \"campaign_type\", must be one of #{validator.allowable_values}." + end + @campaign_type = campaign_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] creation_status Object to be assigned + def creation_status=(creation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(creation_status) + fail ArgumentError, "invalid value for \"creation_status\", must be one of #{validator.allowable_values}." + end + @creation_status = creation_status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] vouchers_generation_status Object to be assigned + def vouchers_generation_status=(vouchers_generation_status) + validator = EnumAttributeValidator.new('String', ["DONE", "IN_PROGRESS", "FAILED", "DRAFT", "MODIFYING"]) + unless validator.valid?(vouchers_generation_status) + fail ArgumentError, "invalid value for \"vouchers_generation_status\", must be one of #{validator.allowable_values}." + end + @vouchers_generation_status = vouchers_generation_status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + description == o.description && + campaign_type == o.campaign_type && + type == o.type && + voucher == o.voucher && + auto_join == o.auto_join && + join_once == o.join_once && + use_voucher_metadata_schema == o.use_voucher_metadata_schema && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + activity_duration_after_publishing == o.activity_duration_after_publishing && + vouchers_count == o.vouchers_count && + start_date == o.start_date && + expiration_date == o.expiration_date && + active == o.active && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + category == o.category && + creation_status == o.creation_status && + vouchers_generation_status == o.vouchers_generation_status && + protected == o.protected && + category_id == o.category_id && + categories == o.categories && + object == o.object && + referral_program == o.referral_program && + loyalty_tiers_expiration == o.loyalty_tiers_expiration && + promotion == o.promotion && + validation_rules_assignments == o.validation_rules_assignments + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, description, campaign_type, type, voucher, auto_join, join_once, use_voucher_metadata_schema, validity_timeframe, validity_day_of_week, activity_duration_after_publishing, vouchers_count, start_date, expiration_date, active, metadata, created_at, updated_at, category, creation_status, vouchers_generation_status, protected, category_id, categories, object, referral_program, loyalty_tiers_expiration, promotion, validation_rules_assignments].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_vouchers_create_base_request_body.rb b/lib/VoucherifySdk/models/campaigns_vouchers_create_base_request_body.rb new file mode 100644 index 00000000..db2ef6ab --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_vouchers_create_base_request_body.rb @@ -0,0 +1,264 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CampaignsVouchersCreateBaseRequestBody + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :redemption + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # Activation timestamp defines when the voucher starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the voucher expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'category' => :'category', + :'metadata' => :'metadata', + :'redemption' => :'redemption', + :'additional_info' => :'additional_info', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'category' => :'String', + :'metadata' => :'Object', + :'redemption' => :'CampaignsImportVoucherItemRedemption', + :'additional_info' => :'String', + :'start_date' => :'Time', + :'expiration_date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsVouchersCreateBaseRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsVouchersCreateBaseRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + category == o.category && + metadata == o.metadata && + redemption == o.redemption && + additional_info == o.additional_info && + start_date == o.start_date && + expiration_date == o.expiration_date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [category, metadata, redemption, additional_info, start_date, expiration_date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_vouchers_create_in_bulk_request_body.rb b/lib/VoucherifySdk/models/campaigns_vouchers_create_in_bulk_request_body.rb new file mode 100644 index 00000000..1264d377 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_vouchers_create_in_bulk_request_body.rb @@ -0,0 +1,291 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/campaigns/{campaignId}/vouchers`. + class CampaignsVouchersCreateInBulkRequestBody + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :redemption + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # Activation timestamp defines when the voucher starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the voucher expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + # Unique voucher code. + attr_accessor :code + + attr_accessor :code_config + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'category' => :'category', + :'metadata' => :'metadata', + :'redemption' => :'redemption', + :'additional_info' => :'additional_info', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'code' => :'code', + :'code_config' => :'code_config' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'category' => :'String', + :'metadata' => :'Object', + :'redemption' => :'CampaignsImportVoucherItemRedemption', + :'additional_info' => :'String', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'code' => :'String', + :'code_config' => :'CodeConfig' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsVouchersCreateBaseRequestBody' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsVouchersCreateInBulkRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsVouchersCreateInBulkRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'code_config') + self.code_config = attributes[:'code_config'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + category == o.category && + metadata == o.metadata && + redemption == o.redemption && + additional_info == o.additional_info && + start_date == o.start_date && + expiration_date == o.expiration_date && + code == o.code && + code_config == o.code_config + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [category, metadata, redemption, additional_info, start_date, expiration_date, code, code_config].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_vouchers_create_in_bulk_response_body.rb b/lib/VoucherifySdk/models/campaigns_vouchers_create_in_bulk_response_body.rb new file mode 100644 index 00000000..8c24941c --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_vouchers_create_in_bulk_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/campaigns/{campaignId}/vouchers/{code}`. + class CampaignsVouchersCreateInBulkResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsVouchersCreateInBulkResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsVouchersCreateInBulkResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_vouchers_create_request_body.rb b/lib/VoucherifySdk/models/campaigns_vouchers_create_request_body.rb new file mode 100644 index 00000000..8ba87d5b --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_vouchers_create_request_body.rb @@ -0,0 +1,272 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/campaigns/{campaignId}/vouchers/{code}`. + class CampaignsVouchersCreateRequestBody + # The category assigned to the campaign. Either pass this parameter OR the `category_id`. + attr_accessor :category + + # The metadata object stores all custom attributes assigned to the voucher. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :redemption + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # Activation timestamp defines when the voucher starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the voucher expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'category' => :'category', + :'metadata' => :'metadata', + :'redemption' => :'redemption', + :'additional_info' => :'additional_info', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'category' => :'String', + :'metadata' => :'Object', + :'redemption' => :'CampaignsImportVoucherItemRedemption', + :'additional_info' => :'String', + :'start_date' => :'Time', + :'expiration_date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CampaignsVouchersCreateBaseRequestBody' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsVouchersCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsVouchersCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + category == o.category && + metadata == o.metadata && + redemption == o.redemption && + additional_info == o.additional_info && + start_date == o.start_date && + expiration_date == o.expiration_date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [category, metadata, redemption, additional_info, start_date, expiration_date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/campaigns_vouchers_create_response_body.rb b/lib/VoucherifySdk/models/campaigns_vouchers_create_response_body.rb new file mode 100644 index 00000000..da389408 --- /dev/null +++ b/lib/VoucherifySdk/models/campaigns_vouchers_create_response_body.rb @@ -0,0 +1,547 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/campaigns/{campaignId}/vouchers/{code}` and **POST** `/campaigns/{campaignId}/vouchers`. + class CampaignsVouchersCreateResponseBody + # Assigned by the Voucherify API, identifies the voucher. + attr_accessor :id + + # A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. + attr_accessor :code + + # A unique campaign name, identifies the voucher's parent campaign. + attr_accessor :campaign + + # Assigned by the Voucherify API, identifies the voucher's parent campaign. + attr_accessor :campaign_id + + # Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. + attr_accessor :category + + # Unique category ID assigned by Voucherify. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # Defines the type of the voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher + attr_accessor :active + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :assets + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Timestamp representing the date and time when the voucher was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique customer ID of voucher owner. + attr_accessor :holder_id + + attr_accessor :holder + + # The type of object represented by JSON. Default is `voucher`. + attr_accessor :object + + attr_accessor :distributions + + # Flag indicating whether this voucher is deleted. + attr_accessor :deleted + + attr_accessor :validation_rules_assignments + + attr_accessor :publish + + attr_accessor :redemption + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'category' => :'category', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'type' => :'type', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'active' => :'active', + :'additional_info' => :'additional_info', + :'metadata' => :'metadata', + :'assets' => :'assets', + :'is_referral_code' => :'is_referral_code', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'holder_id' => :'holder_id', + :'holder' => :'holder', + :'object' => :'object', + :'distributions' => :'distributions', + :'deleted' => :'deleted', + :'validation_rules_assignments' => :'validation_rules_assignments', + :'publish' => :'publish', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'campaign' => :'String', + :'campaign_id' => :'String', + :'category' => :'String', + :'category_id' => :'String', + :'categories' => :'Array', + :'type' => :'String', + :'discount' => :'Discount', + :'gift' => :'VoucherGift', + :'loyalty_card' => :'VoucherLoyaltyCard', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'VoucherValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'active' => :'Boolean', + :'additional_info' => :'String', + :'metadata' => :'Object', + :'assets' => :'VoucherAssets', + :'is_referral_code' => :'Boolean', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'holder_id' => :'String', + :'holder' => :'SimpleCustomer', + :'object' => :'String', + :'distributions' => :'Array', + :'deleted' => :'Boolean', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList', + :'publish' => :'VoucherPublish', + :'redemption' => :'VoucherRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'active', + :'is_referral_code', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Voucher' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CampaignsVouchersCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CampaignsVouchersCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'distributions') + if (value = attributes[:'distributions']).is_a?(Array) + self.distributions = value + end + end + + if attributes.key?(:'deleted') + self.deleted = attributes[:'deleted'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + + if attributes.key?(:'publish') + self.publish = attributes[:'publish'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + campaign == o.campaign && + campaign_id == o.campaign_id && + category == o.category && + category_id == o.category_id && + categories == o.categories && + type == o.type && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + active == o.active && + additional_info == o.additional_info && + metadata == o.metadata && + assets == o.assets && + is_referral_code == o.is_referral_code && + created_at == o.created_at && + updated_at == o.updated_at && + holder_id == o.holder_id && + holder == o.holder && + object == o.object && + distributions == o.distributions && + deleted == o.deleted && + validation_rules_assignments == o.validation_rules_assignments && + publish == o.publish && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, campaign, campaign_id, category, category_id, categories, type, discount, gift, loyalty_card, start_date, expiration_date, validity_timeframe, validity_day_of_week, active, additional_info, metadata, assets, is_referral_code, created_at, updated_at, holder_id, holder, object, distributions, deleted, validation_rules_assignments, publish, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/categories_create_request_body.rb b/lib/VoucherifySdk/models/categories_create_request_body.rb new file mode 100644 index 00000000..70cf59b9 --- /dev/null +++ b/lib/VoucherifySdk/models/categories_create_request_body.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/categories`. + class CategoriesCreateRequestBody + # Category name. + attr_accessor :name + + # Category hierarchy. + attr_accessor :hierarchy + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'hierarchy' => :'hierarchy' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'hierarchy' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CategoriesCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CategoriesCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + else + self.hierarchy = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @hierarchy.nil? + invalid_properties.push('invalid value for "hierarchy", hierarchy cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @hierarchy.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + hierarchy == o.hierarchy + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, hierarchy].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/categories_create_response_body.rb b/lib/VoucherifySdk/models/categories_create_response_body.rb new file mode 100644 index 00000000..be086223 --- /dev/null +++ b/lib/VoucherifySdk/models/categories_create_response_body.rb @@ -0,0 +1,324 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/categories`. + class CategoriesCreateResponseBody + # Unique category ID assigned by Voucherify. + attr_accessor :id + + # Category name. + attr_accessor :name + + # Category hierarchy. + attr_accessor :hierarchy + + attr_accessor :object + + # Timestamp representing the date and time when the category was created in ISO 8601 format. + attr_accessor :created_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'hierarchy' => :'hierarchy', + :'object' => :'object', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'hierarchy' => :'Integer', + :'object' => :'String', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CategoriesCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CategoriesCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + else + self.hierarchy = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'category' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @hierarchy.nil? + invalid_properties.push('invalid value for "hierarchy", hierarchy cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @hierarchy.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["category"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["category"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + hierarchy == o.hierarchy && + object == o.object && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, hierarchy, object, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/categories_get_response_body.rb b/lib/VoucherifySdk/models/categories_get_response_body.rb new file mode 100644 index 00000000..fda0cec2 --- /dev/null +++ b/lib/VoucherifySdk/models/categories_get_response_body.rb @@ -0,0 +1,364 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/categories/{categoryId}`. + class CategoriesGetResponseBody + # Unique category ID assigned by Voucherify. + attr_accessor :id + + # Category name. + attr_accessor :name + + # Category hierarchy. + attr_accessor :hierarchy + + # The type of object represented by the JSON. This object stores information about the category. + attr_accessor :object + + # Timestamp representing the date and time when the category was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the category was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of the stacking rule eligibility. + attr_accessor :stacking_rules_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'hierarchy' => :'hierarchy', + :'object' => :'object', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'stacking_rules_type' => :'stacking_rules_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'hierarchy' => :'Integer', + :'object' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'stacking_rules_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Category' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CategoriesGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CategoriesGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + else + self.hierarchy = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'category' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'stacking_rules_type') + self.stacking_rules_type = attributes[:'stacking_rules_type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @hierarchy.nil? + invalid_properties.push('invalid value for "hierarchy", hierarchy cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @hierarchy.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["category"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + stacking_rules_type_validator = EnumAttributeValidator.new('String', ["JOINT", "EXCLUSIVE"]) + return false unless stacking_rules_type_validator.valid?(@stacking_rules_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["category"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] stacking_rules_type Object to be assigned + def stacking_rules_type=(stacking_rules_type) + validator = EnumAttributeValidator.new('String', ["JOINT", "EXCLUSIVE"]) + unless validator.valid?(stacking_rules_type) + fail ArgumentError, "invalid value for \"stacking_rules_type\", must be one of #{validator.allowable_values}." + end + @stacking_rules_type = stacking_rules_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + hierarchy == o.hierarchy && + object == o.object && + created_at == o.created_at && + updated_at == o.updated_at && + stacking_rules_type == o.stacking_rules_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, hierarchy, object, created_at, updated_at, stacking_rules_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/categories_list_response_body.rb b/lib/VoucherifySdk/models/categories_list_response_body.rb new file mode 100644 index 00000000..3aa00464 --- /dev/null +++ b/lib/VoucherifySdk/models/categories_list_response_body.rb @@ -0,0 +1,321 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/categories`. + class CategoriesListResponseBody + # The type of object represented by JSON. This object stores information about categories in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of category objects. + attr_accessor :data_ref + + attr_accessor :data + + # Total number of categories. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CategoriesListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CategoriesListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/categories_update_request_body.rb b/lib/VoucherifySdk/models/categories_update_request_body.rb new file mode 100644 index 00000000..165519b8 --- /dev/null +++ b/lib/VoucherifySdk/models/categories_update_request_body.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **PUT** `/categories/{categoryId}`. + class CategoriesUpdateRequestBody + # Category name. + attr_accessor :name + + # Category hierarchy. + attr_accessor :hierarchy + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'hierarchy' => :'hierarchy' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'hierarchy' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CategoriesUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CategoriesUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + else + self.hierarchy = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @hierarchy.nil? + invalid_properties.push('invalid value for "hierarchy", hierarchy cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @hierarchy.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + hierarchy == o.hierarchy + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, hierarchy].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/categories_update_response_body.rb b/lib/VoucherifySdk/models/categories_update_response_body.rb new file mode 100644 index 00000000..9f75933b --- /dev/null +++ b/lib/VoucherifySdk/models/categories_update_response_body.rb @@ -0,0 +1,341 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/categories/{categoryId}`. + class CategoriesUpdateResponseBody + # Unique category ID assigned by Voucherify. + attr_accessor :id + + # Category name. + attr_accessor :name + + # Category hierarchy. + attr_accessor :hierarchy + + attr_accessor :object + + # Timestamp representing the date and time when the category was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the category was updated in ISO 8601 format. + attr_accessor :updated_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'hierarchy' => :'hierarchy', + :'object' => :'object', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'hierarchy' => :'Integer', + :'object' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CategoriesUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CategoriesUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + else + self.hierarchy = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'category' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @hierarchy.nil? + invalid_properties.push('invalid value for "hierarchy", hierarchy cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @updated_at.nil? + invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @hierarchy.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["category"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @updated_at.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["category"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + hierarchy == o.hierarchy && + object == o.object && + created_at == o.created_at && + updated_at == o.updated_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, hierarchy, object, created_at, updated_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/category.rb b/lib/VoucherifySdk/models/category.rb new file mode 100644 index 00000000..508456a3 --- /dev/null +++ b/lib/VoucherifySdk/models/category.rb @@ -0,0 +1,357 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a category. + class Category + # Unique category ID assigned by Voucherify. + attr_accessor :id + + # Category name. + attr_accessor :name + + # Category hierarchy. + attr_accessor :hierarchy + + # The type of object represented by the JSON. This object stores information about the category. + attr_accessor :object + + # Timestamp representing the date and time when the category was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the category was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of the stacking rule eligibility. + attr_accessor :stacking_rules_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'hierarchy' => :'hierarchy', + :'object' => :'object', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'stacking_rules_type' => :'stacking_rules_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'hierarchy' => :'Integer', + :'object' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'stacking_rules_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Category` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Category`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + else + self.hierarchy = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'category' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'stacking_rules_type') + self.stacking_rules_type = attributes[:'stacking_rules_type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @hierarchy.nil? + invalid_properties.push('invalid value for "hierarchy", hierarchy cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @hierarchy.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["category"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + stacking_rules_type_validator = EnumAttributeValidator.new('String', ["JOINT", "EXCLUSIVE"]) + return false unless stacking_rules_type_validator.valid?(@stacking_rules_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["category"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] stacking_rules_type Object to be assigned + def stacking_rules_type=(stacking_rules_type) + validator = EnumAttributeValidator.new('String', ["JOINT", "EXCLUSIVE"]) + unless validator.valid?(stacking_rules_type) + fail ArgumentError, "invalid value for \"stacking_rules_type\", must be one of #{validator.allowable_values}." + end + @stacking_rules_type = stacking_rules_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + hierarchy == o.hierarchy && + object == o.object && + created_at == o.created_at && + updated_at == o.updated_at && + stacking_rules_type == o.stacking_rules_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, hierarchy, object, created_at, updated_at, stacking_rules_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_events_create_request_body.rb b/lib/VoucherifySdk/models/client_events_create_request_body.rb new file mode 100644 index 00000000..c4af2345 --- /dev/null +++ b/lib/VoucherifySdk/models/client_events_create_request_body.rb @@ -0,0 +1,295 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/events`. + class ClientEventsCreateRequestBody + # Event name. This is the same name that you used to define a custom event in the **Dashboard** > **Project Settings** > **Event Schema**. + attr_accessor :event + + attr_accessor :customer + + attr_accessor :referral + + attr_accessor :loyalty + + # The metadata object stores all custom attributes assigned to the event. A set of key/value pairs that you can attach to an event object. It can be useful for storing additional information about the event in a structured format. Event metadata schema is defined in the **Dashboard** > **Project Settings** > **Event Schema** > **Edit particular event** > **Metadata property definition**. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event' => :'event', + :'customer' => :'customer', + :'referral' => :'referral', + :'loyalty' => :'loyalty', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event' => :'String', + :'customer' => :'Customer', + :'referral' => :'ClientEventsCreateRequestBodyReferral', + :'loyalty' => :'ClientEventsCreateRequestBodyLoyalty', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientEventsCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientEventsCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event') + self.event = attributes[:'event'] + else + self.event = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'referral') + self.referral = attributes[:'referral'] + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @event.nil? + invalid_properties.push('invalid value for "event", event cannot be nil.') + end + + if @event.to_s.length > 300 + invalid_properties.push('invalid value for "event", the character length must be smaller than or equal to 300.') + end + + if @event.to_s.length < 1 + invalid_properties.push('invalid value for "event", the character length must be great than or equal to 1.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @event.nil? + return false if @event.to_s.length > 300 + return false if @event.to_s.length < 1 + return false if @customer.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] event Value to be assigned + def event=(event) + if event.nil? + fail ArgumentError, 'event cannot be nil' + end + + if event.to_s.length > 300 + fail ArgumentError, 'invalid value for "event", the character length must be smaller than or equal to 300.' + end + + if event.to_s.length < 1 + fail ArgumentError, 'invalid value for "event", the character length must be great than or equal to 1.' + end + + @event = event + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event == o.event && + customer == o.customer && + referral == o.referral && + loyalty == o.loyalty && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event, customer, referral, loyalty, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_events_create_request_body_loyalty.rb b/lib/VoucherifySdk/models/client_events_create_request_body_loyalty.rb new file mode 100644 index 00000000..14af252f --- /dev/null +++ b/lib/VoucherifySdk/models/client_events_create_request_body_loyalty.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # If an earning rule in a loyalty program is based on a custom event. This objects let's you specify the loyalty card to which the custom event should be attributed to. + class ClientEventsCreateRequestBodyLoyalty + # Code of the loyalty card to receive points based on the calculation method defined in the related earning rule. An earning rule is triggered for the loyalty card when the event passed in the `event` parameter of the request payload gets sent along with this loyalty card code. + attr_accessor :code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientEventsCreateRequestBodyLoyalty` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientEventsCreateRequestBodyLoyalty`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_events_create_request_body_referral.rb b/lib/VoucherifySdk/models/client_events_create_request_body_referral.rb new file mode 100644 index 00000000..c04bd7fd --- /dev/null +++ b/lib/VoucherifySdk/models/client_events_create_request_body_referral.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # If a **conversion event** for a referral program is set to a custom event, then you need to send the referral code in the payload to make a record of the conversion event. + class ClientEventsCreateRequestBodyReferral + # A code through which a new visitor has been referred to a service. + attr_accessor :code + + # Unique ID of the referring person - it is optional and not required if the referral **code** is provided. + attr_accessor :referrer_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'referrer_id' => :'referrer_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'String', + :'referrer_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientEventsCreateRequestBodyReferral` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientEventsCreateRequestBodyReferral`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code && + referrer_id == o.referrer_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [code, referrer_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_events_create_response_body.rb b/lib/VoucherifySdk/models/client_events_create_response_body.rb new file mode 100644 index 00000000..6f96400d --- /dev/null +++ b/lib/VoucherifySdk/models/client_events_create_response_body.rb @@ -0,0 +1,316 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/events`. + class ClientEventsCreateResponseBody + # The object represented is an `event`. + attr_accessor :object + + # The event name. + attr_accessor :type + + attr_accessor :customer + + # A `null` referral object. + attr_accessor :referral + + # A `null` loyalty object. + attr_accessor :loyalty + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'type' => :'type', + :'customer' => :'customer', + :'referral' => :'referral', + :'loyalty' => :'loyalty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'type' => :'String', + :'customer' => :'SimpleCustomerRequiredObjectType', + :'referral' => :'Object', + :'loyalty' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'referral', + :'loyalty' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientEventsCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientEventsCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'event' + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'referral') + self.referral = attributes[:'referral'] + else + self.referral = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["event"]) + return false unless object_validator.valid?(@object) + return false if @type.nil? + return false if @customer.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["event"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + type == o.type && + customer == o.customer && + referral == o.referral && + loyalty == o.loyalty + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, type, customer, referral, loyalty].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_qualifications_check_eligibility_request_body.rb b/lib/VoucherifySdk/models/client_qualifications_check_eligibility_request_body.rb new file mode 100644 index 00000000..88ee5290 --- /dev/null +++ b/lib/VoucherifySdk/models/client_qualifications_check_eligibility_request_body.rb @@ -0,0 +1,319 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/qualifications`. + class ClientQualificationsCheckEligibilityRequestBody + attr_accessor :customer + + attr_accessor :order + + # Defines which resources Voucherify will use. The `ADVANCED` mode is available after purchase only. + attr_accessor :mode + + # Is correspondent to Customer's source_id + attr_accessor :tracking_id + + # Defines the scenario Voucherify should consider during the qualification process. - `ALL` - Scenario that returns all redeemables available for the customer in one API request. This scenario is used by default when no value is selected. - `CUSTOMER_WALLET` - returns vouchers applicable to the customer’s cart based on the vouchers assigned to the customer’s profile. - `AUDIENCE_ONLY` - returns all vouchers, promotion tiers, and campaigns available to the customer. Voucherify validates the rules based on the customer profile only. - `PRODUCTS` - returns all promotions available for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT` - returns all promotions available for products when a discount is defined as applicable to specific item(s). - `PROMOTION_STACKS` - returns the applicable promotion stacks. - `PRODUCTS_BY_CUSTOMER` - returns all promotions available for a customer for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT_BY_CUSTOMER` - returns all promotions available for a customer for products when a discount is defined as applicable to specific item(s). + attr_accessor :scenario + + attr_accessor :options + + # A set of key/value pairs that you can send in the request body to check against redeemables requiring **redemption** metadata validation rules to be satisfied. The validation runs against rules that are defined through the [Create Validation Rules](ref:create-validation-rules) endpoint or via the Dashboard; in the _Advanced Rule Builder_ → _Advanced_ → _Redemption metadata satisfy_ or _Basic Builder_ → _Attributes match_ → _REDEMPTION METADATA_. [Read more](https://support.voucherify.io/article/148-how-to-build-a-rule). + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'order' => :'order', + :'mode' => :'mode', + :'tracking_id' => :'tracking_id', + :'scenario' => :'scenario', + :'options' => :'options', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'Customer', + :'order' => :'Order', + :'mode' => :'String', + :'tracking_id' => :'String', + :'scenario' => :'String', + :'options' => :'QualificationsOption', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientQualificationsCheckEligibilityRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientQualificationsCheckEligibilityRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'mode') + self.mode = attributes[:'mode'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'scenario') + self.scenario = attributes[:'scenario'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + mode_validator = EnumAttributeValidator.new('String', ["BASIC", "ADVANCED"]) + return false unless mode_validator.valid?(@mode) + scenario_validator = EnumAttributeValidator.new('String', ["ALL", "CUSTOMER_WALLET", "AUDIENCE_ONLY", "PRODUCTS", "PRODUCTS_DISCOUNT", "PROMOTION_STACKS", "PRODUCTS_BY_CUSTOMER", "PRODUCTS_DISCOUNT_BY_CUSTOMER"]) + return false unless scenario_validator.valid?(@scenario) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] mode Object to be assigned + def mode=(mode) + validator = EnumAttributeValidator.new('String', ["BASIC", "ADVANCED"]) + unless validator.valid?(mode) + fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}." + end + @mode = mode + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] scenario Object to be assigned + def scenario=(scenario) + validator = EnumAttributeValidator.new('String', ["ALL", "CUSTOMER_WALLET", "AUDIENCE_ONLY", "PRODUCTS", "PRODUCTS_DISCOUNT", "PROMOTION_STACKS", "PRODUCTS_BY_CUSTOMER", "PRODUCTS_DISCOUNT_BY_CUSTOMER"]) + unless validator.valid?(scenario) + fail ArgumentError, "invalid value for \"scenario\", must be one of #{validator.allowable_values}." + end + @scenario = scenario + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + order == o.order && + mode == o.mode && + tracking_id == o.tracking_id && + scenario == o.scenario && + options == o.options && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, order, mode, tracking_id, scenario, options, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_qualifications_check_eligibility_response_body.rb b/lib/VoucherifySdk/models/client_qualifications_check_eligibility_response_body.rb new file mode 100644 index 00000000..2111dd2d --- /dev/null +++ b/lib/VoucherifySdk/models/client_qualifications_check_eligibility_response_body.rb @@ -0,0 +1,243 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/qualifications`. + class ClientQualificationsCheckEligibilityResponseBody + attr_accessor :redeemables + + # This identifier is generated during voucher qualification based on your internal id (e.g., email, database ID). This is a hashed customer source ID. + attr_accessor :tracking_id + + attr_accessor :order + + attr_accessor :stacking_rules + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables' => :'redeemables', + :'tracking_id' => :'tracking_id', + :'order' => :'order', + :'stacking_rules' => :'stacking_rules' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables' => :'QualificationsRedeemables', + :'tracking_id' => :'String', + :'order' => :'OrderCalculated', + :'stacking_rules' => :'StackingRules' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientQualificationsCheckEligibilityResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientQualificationsCheckEligibilityResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables') + self.redeemables = attributes[:'redeemables'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'stacking_rules') + self.stacking_rules = attributes[:'stacking_rules'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables == o.redeemables && + tracking_id == o.tracking_id && + order == o.order && + stacking_rules == o.stacking_rules + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables, tracking_id, order, stacking_rules].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_redemptions_redeem_request_body.rb b/lib/VoucherifySdk/models/client_redemptions_redeem_request_body.rb new file mode 100644 index 00000000..86588767 --- /dev/null +++ b/lib/VoucherifySdk/models/client_redemptions_redeem_request_body.rb @@ -0,0 +1,316 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/redemptions`. + class ClientRedemptionsRedeemRequestBody + # An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. + attr_accessor :redeemables + + attr_accessor :order + + attr_accessor :customer + + attr_accessor :session + + # Is correspondent to Customer's source_id + attr_accessor :tracking_id + + # A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. + attr_accessor :metadata + + attr_accessor :options + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables' => :'redeemables', + :'order' => :'order', + :'customer' => :'customer', + :'session' => :'session', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'options' => :'options' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables' => :'Array', + :'order' => :'Order', + :'customer' => :'Customer', + :'session' => :'Session', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'options' => :'ClientRedemptionsRedeemRequestBodyAllOfOptions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'StackableValidateRedeemBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientRedemptionsRedeemRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientRedemptionsRedeemRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + else + self.redeemables = nil + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'session') + self.session = attributes[:'session'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemables.nil? + invalid_properties.push('invalid value for "redeemables", redeemables cannot be nil.') + end + + if @redeemables.length > 5 + invalid_properties.push('invalid value for "redeemables", number of items must be less than or equal to 5.') + end + + if @redeemables.length < 1 + invalid_properties.push('invalid value for "redeemables", number of items must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemables.nil? + return false if @redeemables.length > 5 + return false if @redeemables.length < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] redeemables Value to be assigned + def redeemables=(redeemables) + if redeemables.nil? + fail ArgumentError, 'redeemables cannot be nil' + end + + if redeemables.length > 5 + fail ArgumentError, 'invalid value for "redeemables", number of items must be less than or equal to 5.' + end + + if redeemables.length < 1 + fail ArgumentError, 'invalid value for "redeemables", number of items must be greater than or equal to 1.' + end + + @redeemables = redeemables + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables == o.redeemables && + order == o.order && + customer == o.customer && + session == o.session && + tracking_id == o.tracking_id && + metadata == o.metadata && + options == o.options + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables, order, customer, session, tracking_id, metadata, options].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_redemptions_redeem_request_body_all_of_options.rb b/lib/VoucherifySdk/models/client_redemptions_redeem_request_body_all_of_options.rb new file mode 100644 index 00000000..54d45ee9 --- /dev/null +++ b/lib/VoucherifySdk/models/client_redemptions_redeem_request_body_all_of_options.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Configure parameters returned in the response. + class ClientRedemptionsRedeemRequestBodyAllOfOptions + # Expand array lets you configure params included in the response. Depending on the strings included in the array, the response will contain different details. | **Expand Option** | **Response Body** | |:---|:---| | [\"order\"] | - Same response as fallback response (without an options object).
- Order data with calculated discounts are listed in each child redeemable object.
- Metadata not included for each discount type. | | [\"redeemable\"] | Expands redeemable objects by including `metadata` for each discount type. | | [\"order\", \"redeemable\"] | - Order data with calculated discounts are listed in each child redeemable object.
- Includes `metadata` for each discount type. | | [\"redeemable\", \"redemption\", \"category\"] | - Returns each discount type's `metadata` in each child redemption object.
- Returns redemption object `metadata`.
- Returns an expanded `categories` object, showing details about the category. | + attr_accessor :expand + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'expand' => :'expand' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'expand' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientRedemptionsRedeemRequestBodyAllOfOptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientRedemptionsRedeemRequestBodyAllOfOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'expand') + if (value = attributes[:'expand']).is_a?(Array) + self.expand = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + expand == o.expand + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [expand].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_redemptions_redeem_response_body.rb b/lib/VoucherifySdk/models/client_redemptions_redeem_response_body.rb new file mode 100644 index 00000000..b65b0c8c --- /dev/null +++ b/lib/VoucherifySdk/models/client_redemptions_redeem_response_body.rb @@ -0,0 +1,259 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/redemptions`. + class ClientRedemptionsRedeemResponseBody + attr_accessor :redemptions + + attr_accessor :parent_redemption + + attr_accessor :order + + # Lists validation results of each inapplicable redeemable. + attr_accessor :inapplicable_redeemables + + # Lists validation results of each redeemable. If a redeemable can be applied, the API returns `\"status\": \"APPLICABLE\"`. + attr_accessor :skipped_redeemables + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redemptions' => :'redemptions', + :'parent_redemption' => :'parent_redemption', + :'order' => :'order', + :'inapplicable_redeemables' => :'inapplicable_redeemables', + :'skipped_redeemables' => :'skipped_redeemables' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redemptions' => :'Array', + :'parent_redemption' => :'Redemption', + :'order' => :'OrderCalculated', + :'inapplicable_redeemables' => :'Array', + :'skipped_redeemables' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientRedemptionsRedeemResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientRedemptionsRedeemResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Array) + self.redemptions = value + end + end + + if attributes.key?(:'parent_redemption') + self.parent_redemption = attributes[:'parent_redemption'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'inapplicable_redeemables') + if (value = attributes[:'inapplicable_redeemables']).is_a?(Array) + self.inapplicable_redeemables = value + end + end + + if attributes.key?(:'skipped_redeemables') + if (value = attributes[:'skipped_redeemables']).is_a?(Array) + self.skipped_redeemables = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redemptions == o.redemptions && + parent_redemption == o.parent_redemption && + order == o.order && + inapplicable_redeemables == o.inapplicable_redeemables && + skipped_redeemables == o.skipped_redeemables + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redemptions, parent_redemption, order, inapplicable_redeemables, skipped_redeemables].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_validations_validate_request_body.rb b/lib/VoucherifySdk/models/client_validations_validate_request_body.rb new file mode 100644 index 00000000..6193ab31 --- /dev/null +++ b/lib/VoucherifySdk/models/client_validations_validate_request_body.rb @@ -0,0 +1,316 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/validations`. + class ClientValidationsValidateRequestBody + # An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. + attr_accessor :redeemables + + attr_accessor :order + + attr_accessor :customer + + attr_accessor :session + + # Is correspondent to Customer's source_id + attr_accessor :tracking_id + + # A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. + attr_accessor :metadata + + attr_accessor :options + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables' => :'redeemables', + :'order' => :'order', + :'customer' => :'customer', + :'session' => :'session', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'options' => :'options' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables' => :'Array', + :'order' => :'Order', + :'customer' => :'Customer', + :'session' => :'Session', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'options' => :'ClientValidationsValidateRequestBodyAllOfOptions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'StackableValidateRedeemBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientValidationsValidateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientValidationsValidateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + else + self.redeemables = nil + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'session') + self.session = attributes[:'session'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemables.nil? + invalid_properties.push('invalid value for "redeemables", redeemables cannot be nil.') + end + + if @redeemables.length > 5 + invalid_properties.push('invalid value for "redeemables", number of items must be less than or equal to 5.') + end + + if @redeemables.length < 1 + invalid_properties.push('invalid value for "redeemables", number of items must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemables.nil? + return false if @redeemables.length > 5 + return false if @redeemables.length < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] redeemables Value to be assigned + def redeemables=(redeemables) + if redeemables.nil? + fail ArgumentError, 'redeemables cannot be nil' + end + + if redeemables.length > 5 + fail ArgumentError, 'invalid value for "redeemables", number of items must be less than or equal to 5.' + end + + if redeemables.length < 1 + fail ArgumentError, 'invalid value for "redeemables", number of items must be greater than or equal to 1.' + end + + @redeemables = redeemables + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables == o.redeemables && + order == o.order && + customer == o.customer && + session == o.session && + tracking_id == o.tracking_id && + metadata == o.metadata && + options == o.options + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables, order, customer, session, tracking_id, metadata, options].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_validations_validate_request_body_all_of_options.rb b/lib/VoucherifySdk/models/client_validations_validate_request_body_all_of_options.rb new file mode 100644 index 00000000..a17879bc --- /dev/null +++ b/lib/VoucherifySdk/models/client_validations_validate_request_body_all_of_options.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Configure parameters returned in the response. + class ClientValidationsValidateRequestBodyAllOfOptions + # The expand array lets you configure the parameters included in the response. Depending on the strings included in the array, the response will contain different details. | **Expand Option** | **Response Body** | |:---|:---| | [\"order\"] | - Same response as fallback response (without an options object).
- Order data with calculated discounts are listed in each child redeemable object.
- Metadata not included for each discount type. | | [\"redeemable\"] | Expands redeemable objects by including `metadata` for each discount type. | | [\"order\", \"redeemable\"] | - Order data with calculated discounts are listed in each child redeemable object.
- Includes `metadata` for each discount type. | | [\"category\"] | - Returns an expanded `categories` object, showing details about the category. | + attr_accessor :expand + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'expand' => :'expand' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'expand' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientValidationsValidateRequestBodyAllOfOptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientValidationsValidateRequestBodyAllOfOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'expand') + if (value = attributes[:'expand']).is_a?(Array) + self.expand = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + expand == o.expand + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [expand].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/client_validations_validate_response_body.rb b/lib/VoucherifySdk/models/client_validations_validate_response_body.rb new file mode 100644 index 00000000..b0ea8d40 --- /dev/null +++ b/lib/VoucherifySdk/models/client_validations_validate_response_body.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for POST `/validations`. + class ClientValidationsValidateResponseBody + # The result of the validation. It takes all of the redeemables into account and returns a `false` if at least one redeemable is inapplicable. Returns `true` if all redeemables are applicable. + attr_accessor :valid + + # Lists validation results of each redeemable. If redeemables_application_mode=\"PARTIAL\" all redeemables here will be \"APPLICABLE\" + attr_accessor :redeemables + + # Lists validation results of each skipped redeemable. + attr_accessor :skipped_redeemables + + # Lists validation results of each inapplicable redeemable. + attr_accessor :inapplicable_redeemables + + attr_accessor :order + + # Hashed customer source ID. + attr_accessor :tracking_id + + attr_accessor :session + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'valid' => :'valid', + :'redeemables' => :'redeemables', + :'skipped_redeemables' => :'skipped_redeemables', + :'inapplicable_redeemables' => :'inapplicable_redeemables', + :'order' => :'order', + :'tracking_id' => :'tracking_id', + :'session' => :'session' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'valid' => :'Boolean', + :'redeemables' => :'Array', + :'skipped_redeemables' => :'Array', + :'inapplicable_redeemables' => :'Array', + :'order' => :'OrderCalculated', + :'tracking_id' => :'String', + :'session' => :'Session' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationsValidateResponseBody' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ClientValidationsValidateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ClientValidationsValidateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'valid') + self.valid = attributes[:'valid'] + else + self.valid = nil + end + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + else + self.redeemables = nil + end + + if attributes.key?(:'skipped_redeemables') + if (value = attributes[:'skipped_redeemables']).is_a?(Array) + self.skipped_redeemables = value + end + end + + if attributes.key?(:'inapplicable_redeemables') + if (value = attributes[:'inapplicable_redeemables']).is_a?(Array) + self.inapplicable_redeemables = value + end + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'session') + self.session = attributes[:'session'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @valid.nil? + invalid_properties.push('invalid value for "valid", valid cannot be nil.') + end + + if @redeemables.nil? + invalid_properties.push('invalid value for "redeemables", redeemables cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @valid.nil? + return false if @redeemables.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + valid == o.valid && + redeemables == o.redeemables && + skipped_redeemables == o.skipped_redeemables && + inapplicable_redeemables == o.inapplicable_redeemables && + order == o.order && + tracking_id == o.tracking_id && + session == o.session + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [valid, redeemables, skipped_redeemables, inapplicable_redeemables, order, tracking_id, session].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/code_config.rb b/lib/VoucherifySdk/models/code_config.rb new file mode 100644 index 00000000..b942fe8d --- /dev/null +++ b/lib/VoucherifySdk/models/code_config.rb @@ -0,0 +1,266 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema containing information about config used for voucher. Defines code's pattern (prefix, suffix, length, charset, etc). + class CodeConfig + # Number of characters in a generated code (excluding prefix and postfix). + attr_accessor :length + + # Characters that can appear in the code. Examples: - Alphanumeric: `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic: `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic Lowercase: `abcdefghijklmnopqrstuvwxyz` - Alphabetic Uppercase: `ABCDEFGHIJKLMNOPQRSTUVWXYZ` - Numbers: `0123456789` - Custom: a custom character set + attr_accessor :charset + + # A text appended before the code. + attr_accessor :prefix + + # A text appended after the code. + attr_accessor :postfix + + # A pattern for codes where hashes (#) will be replaced with random characters. Overrides `length`. + attr_accessor :pattern + + # The initial count + attr_accessor :initial_count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'length' => :'length', + :'charset' => :'charset', + :'prefix' => :'prefix', + :'postfix' => :'postfix', + :'pattern' => :'pattern', + :'initial_count' => :'initial_count' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'length' => :'Float', + :'charset' => :'String', + :'prefix' => :'String', + :'postfix' => :'String', + :'pattern' => :'String', + :'initial_count' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CodeConfig` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CodeConfig`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'length') + self.length = attributes[:'length'] + end + + if attributes.key?(:'charset') + self.charset = attributes[:'charset'] + end + + if attributes.key?(:'prefix') + self.prefix = attributes[:'prefix'] + end + + if attributes.key?(:'postfix') + self.postfix = attributes[:'postfix'] + end + + if attributes.key?(:'pattern') + self.pattern = attributes[:'pattern'] + end + + if attributes.key?(:'initial_count') + self.initial_count = attributes[:'initial_count'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + length == o.length && + charset == o.charset && + prefix == o.prefix && + postfix == o.postfix && + pattern == o.pattern && + initial_count == o.initial_count + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [length, charset, prefix, postfix, pattern, initial_count].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/code_config_required_length_charset_pattern.rb b/lib/VoucherifySdk/models/code_config_required_length_charset_pattern.rb new file mode 100644 index 00000000..f7440a01 --- /dev/null +++ b/lib/VoucherifySdk/models/code_config_required_length_charset_pattern.rb @@ -0,0 +1,293 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CodeConfigRequiredLengthCharsetPattern + # Number of characters in a generated code (excluding prefix and postfix). + attr_accessor :length + + # Characters that can appear in the code. Examples: - Alphanumeric: `0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic: `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ` - Alphabetic Lowercase: `abcdefghijklmnopqrstuvwxyz` - Alphabetic Uppercase: `ABCDEFGHIJKLMNOPQRSTUVWXYZ` - Numbers: `0123456789` - Custom: a custom character set + attr_accessor :charset + + # A text appended before the code. + attr_accessor :prefix + + # A text appended after the code. + attr_accessor :postfix + + # A pattern for codes where hashes (#) will be replaced with random characters. Overrides `length`. + attr_accessor :pattern + + # The initial count + attr_accessor :initial_count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'length' => :'length', + :'charset' => :'charset', + :'prefix' => :'prefix', + :'postfix' => :'postfix', + :'pattern' => :'pattern', + :'initial_count' => :'initial_count' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'length' => :'Float', + :'charset' => :'String', + :'prefix' => :'String', + :'postfix' => :'String', + :'pattern' => :'String', + :'initial_count' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CodeConfig' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CodeConfigRequiredLengthCharsetPattern` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CodeConfigRequiredLengthCharsetPattern`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'length') + self.length = attributes[:'length'] + else + self.length = nil + end + + if attributes.key?(:'charset') + self.charset = attributes[:'charset'] + else + self.charset = nil + end + + if attributes.key?(:'prefix') + self.prefix = attributes[:'prefix'] + end + + if attributes.key?(:'postfix') + self.postfix = attributes[:'postfix'] + end + + if attributes.key?(:'pattern') + self.pattern = attributes[:'pattern'] + else + self.pattern = nil + end + + if attributes.key?(:'initial_count') + self.initial_count = attributes[:'initial_count'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @length.nil? + invalid_properties.push('invalid value for "length", length cannot be nil.') + end + + if @charset.nil? + invalid_properties.push('invalid value for "charset", charset cannot be nil.') + end + + if @pattern.nil? + invalid_properties.push('invalid value for "pattern", pattern cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @length.nil? + return false if @charset.nil? + return false if @pattern.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + length == o.length && + charset == o.charset && + prefix == o.prefix && + postfix == o.postfix && + pattern == o.pattern && + initial_count == o.initial_count + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [length, charset, prefix, postfix, pattern, initial_count].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/create_publication_base.rb b/lib/VoucherifySdk/models/create_publication_base.rb new file mode 100644 index 00000000..b6358904 --- /dev/null +++ b/lib/VoucherifySdk/models/create_publication_base.rb @@ -0,0 +1,242 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Create publication + class CreatePublicationBase + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If `source_id` is provided only 1 voucher can be published per request. + attr_accessor :source_id + + attr_accessor :customer + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'source_id' => :'source_id', + :'customer' => :'customer', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'source_id' => :'String', + :'customer' => :'Customer', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CreatePublicationBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CreatePublicationBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @customer.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + source_id == o.source_id && + customer == o.customer && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [source_id, customer, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/create_publication_campaign.rb b/lib/VoucherifySdk/models/create_publication_campaign.rb new file mode 100644 index 00000000..9932d883 --- /dev/null +++ b/lib/VoucherifySdk/models/create_publication_campaign.rb @@ -0,0 +1,261 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Create publication with campaign. + class CreatePublicationCampaign + # Name of voucher's parent campaign or unique campaign ID that was assigned by Voucherify. + attr_accessor :name + + # Number of vouchers to be published to customer. + attr_accessor :count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'count' => :'count' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'count' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CreatePublicationCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CreatePublicationCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'count') + self.count = attributes[:'count'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if !@count.nil? && @count > 20 + invalid_properties.push('invalid value for "count", must be smaller than or equal to 20.') + end + + if !@count.nil? && @count < 1 + invalid_properties.push('invalid value for "count", must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if !@count.nil? && @count > 20 + return false if !@count.nil? && @count < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] count Value to be assigned + def count=(count) + if count.nil? + fail ArgumentError, 'count cannot be nil' + end + + if count > 20 + fail ArgumentError, 'invalid value for "count", must be smaller than or equal to 20.' + end + + if count < 1 + fail ArgumentError, 'invalid value for "count", must be greater than or equal to 1.' + end + + @count = count + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + count == o.count + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, count].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/create_publication_with_campaign.rb b/lib/VoucherifySdk/models/create_publication_with_campaign.rb new file mode 100644 index 00000000..a779588a --- /dev/null +++ b/lib/VoucherifySdk/models/create_publication_with_campaign.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Create publication with campaign. + class CreatePublicationWithCampaign + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If `source_id` is provided only 1 voucher can be published per request. + attr_accessor :source_id + + attr_accessor :customer + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + attr_accessor :campaign + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'source_id' => :'source_id', + :'customer' => :'customer', + :'metadata' => :'metadata', + :'campaign' => :'campaign' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'source_id' => :'String', + :'customer' => :'Customer', + :'metadata' => :'Object', + :'campaign' => :'CreatePublicationCampaign' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CreatePublicationBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CreatePublicationWithCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CreatePublicationWithCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + else + self.campaign = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @campaign.nil? + invalid_properties.push('invalid value for "campaign", campaign cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @customer.nil? + return false if @campaign.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + source_id == o.source_id && + customer == o.customer && + metadata == o.metadata && + campaign == o.campaign + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [source_id, customer, metadata, campaign].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/create_publication_with_specific_voucher.rb b/lib/VoucherifySdk/models/create_publication_with_specific_voucher.rb new file mode 100644 index 00000000..292893d0 --- /dev/null +++ b/lib/VoucherifySdk/models/create_publication_with_specific_voucher.rb @@ -0,0 +1,266 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Create publication with specific voucher. + class CreatePublicationWithSpecificVoucher + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. If `source_id` is provided only 1 voucher can be published per request. + attr_accessor :source_id + + attr_accessor :customer + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # Code of voucher being published. + attr_accessor :voucher + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'source_id' => :'source_id', + :'customer' => :'customer', + :'metadata' => :'metadata', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'source_id' => :'String', + :'customer' => :'Customer', + :'metadata' => :'Object', + :'voucher' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CreatePublicationBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CreatePublicationWithSpecificVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CreatePublicationWithSpecificVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + else + self.voucher = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @voucher.nil? + invalid_properties.push('invalid value for "voucher", voucher cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @customer.nil? + return false if @voucher.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + source_id == o.source_id && + customer == o.customer && + metadata == o.metadata && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [source_id, customer, metadata, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/custom_event.rb b/lib/VoucherifySdk/models/custom_event.rb new file mode 100644 index 00000000..450f0d40 --- /dev/null +++ b/lib/VoucherifySdk/models/custom_event.rb @@ -0,0 +1,351 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomEvent + # Unique custom event ID. + attr_accessor :id + + # The object represented is an `event`. + attr_accessor :object + + # The event name. + attr_accessor :type + + attr_accessor :customer + + attr_accessor :referral + + attr_accessor :loyalty + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the custom event. + attr_accessor :metadata + + # Timestamp representing the date and time when the custom event was created in ISO 8601 format. + attr_accessor :created_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'type' => :'type', + :'customer' => :'customer', + :'referral' => :'referral', + :'loyalty' => :'loyalty', + :'metadata' => :'metadata', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'type' => :'String', + :'customer' => :'SimpleCustomerRequiredObjectType', + :'referral' => :'CustomEventReferral', + :'loyalty' => :'Object', + :'metadata' => :'Object', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'event' + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'referral') + self.referral = attributes[:'referral'] + else + self.referral = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @referral.nil? + invalid_properties.push('invalid value for "referral", referral cannot be nil.') + end + + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["event"]) + return false unless object_validator.valid?(@object) + return false if @type.nil? + return false if @customer.nil? + return false if @referral.nil? + return false if @loyalty.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["event"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + type == o.type && + customer == o.customer && + referral == o.referral && + loyalty == o.loyalty && + metadata == o.metadata && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, type, customer, referral, loyalty, metadata, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/custom_event_referral.rb b/lib/VoucherifySdk/models/custom_event_referral.rb new file mode 100644 index 00000000..92f1412f --- /dev/null +++ b/lib/VoucherifySdk/models/custom_event_referral.rb @@ -0,0 +1,236 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Referral object. + class CustomEventReferral + # Unique referrer ID. + attr_accessor :referrer_id + + # Voucher code. + attr_accessor :code + + # Unique voucher ID. + attr_accessor :id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'referrer_id' => :'referrer_id', + :'code' => :'code', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'referrer_id' => :'String', + :'code' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomEventReferral` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomEventReferral`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + referrer_id == o.referrer_id && + code == o.code && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [referrer_id, code, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer.rb b/lib/VoucherifySdk/models/customer.rb new file mode 100644 index 00000000..67d5adfe --- /dev/null +++ b/lib/VoucherifySdk/models/customer.rb @@ -0,0 +1,312 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class Customer + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # The ID of an existing customer. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata', + :'id' => :'id', + :'source_id' => :'source_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object', + :'id' => :'String', + :'source_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Customer` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Customer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata && + id == o.id && + source_id == o.source_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, email, phone, birthday, birthdate, address, metadata, id, source_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_activity.rb b/lib/VoucherifySdk/models/customer_activity.rb new file mode 100644 index 00000000..41266eb8 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_activity.rb @@ -0,0 +1,282 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing customer activity. This is a general object which presents moments from customers' activity. There are all types of different events that customers perform during their journey once they participate in Promotions. Events describe moments when customers redeem coupons and earn points or rewards. The list of all types of activities is listed below. The details describing the activity are collected in a property named `data`. In this object, software integrators will find all further information explaining the event context. + class CustomerActivity + # Unique event ID, assigned by Voucherify. + attr_accessor :id + + # Event type. + attr_accessor :type + + # Contains details about the event. The objects that are returned in the data attribute differ based on the context of the event type. + attr_accessor :data + + # Timestamp representing the date and time when the customer activity occurred in ISO 8601 format. + attr_accessor :created_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type', + :'data' => :'data', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'type' => :'String', + :'data' => :'Array', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerActivity` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerActivity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["customer.confirmed", "customer.created", "customer.updated", "customer.deleted", "customer.referred", "customer.custom_event", "customer.segment.entered", "customer.segment.left", "customer.sms.sent", "customer.sms.recovered", "customer.sms.failed", "customer.email.sent", "customer.email.recovered", "customer.email.failed", "customer.activecampaign.sent", "customer.activecampaign.recovered", "customer.activecampaign.failed", "customer.braze.sent", "customer.braze.recovered", "customer.braze.failed", "customer.mailchimp.sent", "customer.mailchimp.recovered", "customer.mailchimp.failed", "customer.intercom.sent", "customer.intercom.recovered", "customer.intercom.failed", "customer.shopify.sent", "customer.shopify.recovered", "customer.shopify.failed", "customer.klaviyo.sent", "customer.klaviyo.recovered", "customer.klaviyo.failed", "customer.batch.sent", "customer.batch.recovered", "customer.batch.failed", "customer.rewarded", "customer.rewarded.loyalty_points", "customer.voucher.gift.balance_added", "customer.voucher.loyalty_card.points_added", "customer.voucher.loyalty_card.points_transferred", "customer.voucher.loyalty_card.points_expired", "customer.voucher.deleted", "customer.publication.succeeded", "customer.publication.failed", "customer.validation.succeeded", "customer.validation.failed", "customer.redemption.failed", "customer.redemption.succeeded", "customer.redemption.rollback.failed", "customer.redemption.rollback.succeeded", "customer.consents.given", "customer.consents.revoked", "customer.order.canceled", "customer.order.created", "customer.order.fulfilled", "customer.order.paid", "customer.order.processing", "customer.order.updated", "customer.reward_redemptions.created", "customer.reward_redemptions.pending", "customer.reward_redemptions.completed", "customer.reward_redemptions.rolledback", "customer.loyalty.updated", "customer.loyalty.tier.upgraded", "customer.loyalty.tier.downgraded", "customer.loyalty.tier.prolonged", "customer.loyalty.tier.expiration.changed", "customer.loyalty.tier.joined", "customer.loyalty.tier.left"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["customer.confirmed", "customer.created", "customer.updated", "customer.deleted", "customer.referred", "customer.custom_event", "customer.segment.entered", "customer.segment.left", "customer.sms.sent", "customer.sms.recovered", "customer.sms.failed", "customer.email.sent", "customer.email.recovered", "customer.email.failed", "customer.activecampaign.sent", "customer.activecampaign.recovered", "customer.activecampaign.failed", "customer.braze.sent", "customer.braze.recovered", "customer.braze.failed", "customer.mailchimp.sent", "customer.mailchimp.recovered", "customer.mailchimp.failed", "customer.intercom.sent", "customer.intercom.recovered", "customer.intercom.failed", "customer.shopify.sent", "customer.shopify.recovered", "customer.shopify.failed", "customer.klaviyo.sent", "customer.klaviyo.recovered", "customer.klaviyo.failed", "customer.batch.sent", "customer.batch.recovered", "customer.batch.failed", "customer.rewarded", "customer.rewarded.loyalty_points", "customer.voucher.gift.balance_added", "customer.voucher.loyalty_card.points_added", "customer.voucher.loyalty_card.points_transferred", "customer.voucher.loyalty_card.points_expired", "customer.voucher.deleted", "customer.publication.succeeded", "customer.publication.failed", "customer.validation.succeeded", "customer.validation.failed", "customer.redemption.failed", "customer.redemption.succeeded", "customer.redemption.rollback.failed", "customer.redemption.rollback.succeeded", "customer.consents.given", "customer.consents.revoked", "customer.order.canceled", "customer.order.created", "customer.order.fulfilled", "customer.order.paid", "customer.order.processing", "customer.order.updated", "customer.reward_redemptions.created", "customer.reward_redemptions.pending", "customer.reward_redemptions.completed", "customer.reward_redemptions.rolledback", "customer.loyalty.updated", "customer.loyalty.tier.upgraded", "customer.loyalty.tier.downgraded", "customer.loyalty.tier.prolonged", "customer.loyalty.tier.expiration.changed", "customer.loyalty.tier.joined", "customer.loyalty.tier.left"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + type == o.type && + data == o.data && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, type, data, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_activity_data.rb b/lib/VoucherifySdk/models/customer_activity_data.rb new file mode 100644 index 00000000..b7e88317 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_activity_data.rb @@ -0,0 +1,173 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema. + module CustomerActivityData + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'EventCustomerActiveCampaignFailed', + :'EventCustomerActiveCampaignRecovered', + :'EventCustomerActiveCampaignSent', + :'EventCustomerBatchFailed', + :'EventCustomerBatchRecovered', + :'EventCustomerBatchSent', + :'EventCustomerBrazeFailed', + :'EventCustomerBrazeRecovered', + :'EventCustomerBrazeSent', + :'EventCustomerConfirmed', + :'EventCustomerConsentsGiven', + :'EventCustomerConsentsRevoked', + :'EventCustomerCreated', + :'EventCustomerCustomEvent', + :'EventCustomerDeleted', + :'EventCustomerEmailFailed', + :'EventCustomerEmailRecovered', + :'EventCustomerEmailSent', + :'EventCustomerGiftVoucherBalanceAdded', + :'EventCustomerIntercomFailed', + :'EventCustomerIntercomRecovered', + :'EventCustomerIntercomSent', + :'EventCustomerKlaviyoFailed', + :'EventCustomerKlaviyoRecovered', + :'EventCustomerKlaviyoSent', + :'EventCustomerLoyaltyCardPointsAdded', + :'EventCustomerLoyaltyCardPointsTransferred', + :'EventCustomerLoyaltyTierDowngraded', + :'EventCustomerLoyaltyTierExpirationChanged', + :'EventCustomerLoyaltyTierJoined', + :'EventCustomerLoyaltyTierLeft', + :'EventCustomerLoyaltyTierProlonged', + :'EventCustomerLoyaltyTierUpgraded', + :'EventCustomerLoyaltyUpdated', + :'EventCustomerMailchimpFailed', + :'EventCustomerMailchimpRecovered', + :'EventCustomerMailchimpSent', + :'EventCustomerOrderCanceled', + :'EventCustomerOrderCreated', + :'EventCustomerOrderFulfilled', + :'EventCustomerOrderPaid', + :'EventCustomerOrderProcessing', + :'EventCustomerOrderUpdated', + :'EventCustomerPublicationFailed', + :'EventCustomerPublicationSucceeded', + :'EventCustomerRedemptionFailed', + :'EventCustomerRedemptionRollbackFailed', + :'EventCustomerRedemptionRollbackSucceeded', + :'EventCustomerRedemptionSucceeded', + :'EventCustomerReferred', + :'EventCustomerRewardRedemptionsCompleted', + :'EventCustomerRewardRedemptionsCreated', + :'EventCustomerRewardRedemptionsPending', + :'EventCustomerRewardRedemptionsRolledBack', + :'EventCustomerRewarded', + :'EventCustomerRewardedLoyaltyPoints', + :'EventCustomerSegmentEntered', + :'EventCustomerSegmentLeft', + :'EventCustomerShopifyFailed', + :'EventCustomerShopifyRecovered', + :'EventCustomerShopifySent', + :'EventCustomerSmsFailed', + :'EventCustomerSmsRecovered', + :'EventCustomerSmsSent', + :'EventCustomerUpdated', + :'EventCustomerValidationFailed', + :'EventCustomerValidationSucceeded', + :'EventCustomerVoucherDeleted', + :'EventCustomerVouchersLoyaltyPointsExpired' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/customer_base.rb b/lib/VoucherifySdk/models/customer_base.rb new file mode 100644 index 00000000..2f720142 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_base.rb @@ -0,0 +1,285 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomerBase + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'address', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_base_address.rb b/lib/VoucherifySdk/models/customer_base_address.rb new file mode 100644 index 00000000..8b49cdd2 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_base_address.rb @@ -0,0 +1,266 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Customer's address. + class CustomerBaseAddress + # City + attr_accessor :city + + # State + attr_accessor :state + + # First line of address. + attr_accessor :line_1 + + # Second line of address. + attr_accessor :line_2 + + # Country. + attr_accessor :country + + # Postal code. + attr_accessor :postal_code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'city' => :'city', + :'state' => :'state', + :'line_1' => :'line_1', + :'line_2' => :'line_2', + :'country' => :'country', + :'postal_code' => :'postal_code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'city' => :'String', + :'state' => :'String', + :'line_1' => :'String', + :'line_2' => :'String', + :'country' => :'String', + :'postal_code' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerBaseAddress` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerBaseAddress`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'city') + self.city = attributes[:'city'] + end + + if attributes.key?(:'state') + self.state = attributes[:'state'] + end + + if attributes.key?(:'line_1') + self.line_1 = attributes[:'line_1'] + end + + if attributes.key?(:'line_2') + self.line_2 = attributes[:'line_2'] + end + + if attributes.key?(:'country') + self.country = attributes[:'country'] + end + + if attributes.key?(:'postal_code') + self.postal_code = attributes[:'postal_code'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + city == o.city && + state == o.state && + line_1 == o.line_1 && + line_2 == o.line_2 && + country == o.country && + postal_code == o.postal_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [city, state, line_1, line_2, country, postal_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_id.rb b/lib/VoucherifySdk/models/customer_id.rb new file mode 100644 index 00000000..83a18fc9 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_id.rb @@ -0,0 +1,273 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomerId + # A unique identifier of an existing customer. + attr_accessor :id + + # The type of object represented by JSON. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerId` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_loyalty.rb b/lib/VoucherifySdk/models/customer_loyalty.rb new file mode 100644 index 00000000..875cae62 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_loyalty.rb @@ -0,0 +1,258 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomerLoyalty + # Customer's loyalty points. + attr_accessor :points + + # Total number of customers referred by the customer. + attr_accessor :referred_customers + + # Contains campaigns with details about point balances and how many customers were referred by the customer. + attr_accessor :campaigns + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'referred_customers' => :'referred_customers', + :'campaigns' => :'campaigns' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'referred_customers' => :'Integer', + :'campaigns' => :'Hash' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerLoyalty` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerLoyalty`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'referred_customers') + self.referred_customers = attributes[:'referred_customers'] + else + self.referred_customers = nil + end + + if attributes.key?(:'campaigns') + if (value = attributes[:'campaigns']).is_a?(Hash) + self.campaigns = value + end + else + self.campaigns = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @referred_customers.nil? + invalid_properties.push('invalid value for "referred_customers", referred_customers cannot be nil.') + end + + if @campaigns.nil? + invalid_properties.push('invalid value for "campaigns", campaigns cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @points.nil? + return false if @referred_customers.nil? + return false if @campaigns.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + referred_customers == o.referred_customers && + campaigns == o.campaigns + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, referred_customers, campaigns].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_loyalty_campaigns_value.rb b/lib/VoucherifySdk/models/customer_loyalty_campaigns_value.rb new file mode 100644 index 00000000..dfd70318 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_loyalty_campaigns_value.rb @@ -0,0 +1,236 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains details about the point balances left on loyalty cards and the number of referred customers in each campaign. + class CustomerLoyaltyCampaignsValue + # Remaining point balance in campaign. + attr_accessor :points + + # Customer's loyalty tier within the campaign. + attr_accessor :loyalty_tier + + # Number of customers referred by the customer in campaign. + attr_accessor :referred_customers + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'loyalty_tier' => :'loyalty_tier', + :'referred_customers' => :'referred_customers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'loyalty_tier' => :'String', + :'referred_customers' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerLoyaltyCampaignsValue` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerLoyaltyCampaignsValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + + if attributes.key?(:'loyalty_tier') + self.loyalty_tier = attributes[:'loyalty_tier'] + end + + if attributes.key?(:'referred_customers') + self.referred_customers = attributes[:'referred_customers'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + loyalty_tier == o.loyalty_tier && + referred_customers == o.referred_customers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, loyalty_tier, referred_customers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_referrals.rb b/lib/VoucherifySdk/models/customer_referrals.rb new file mode 100644 index 00000000..01865f6a --- /dev/null +++ b/lib/VoucherifySdk/models/customer_referrals.rb @@ -0,0 +1,242 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Summary of customer's referrals, in this case, the customer being the referee, i.e. information about the source of referrals and number of times the customer was referred by other customers. + class CustomerReferrals + # Total number of times this customer received a referral, i.e. was referred by another customer. + attr_accessor :total + + # Contains an array of campaigns that served as the source of a referral for the customer. + attr_accessor :campaigns + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total' => :'total', + :'campaigns' => :'campaigns' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total' => :'Integer', + :'campaigns' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerReferrals` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerReferrals`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'campaigns') + if (value = attributes[:'campaigns']).is_a?(Array) + self.campaigns = value + end + else + self.campaigns = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @campaigns.nil? + invalid_properties.push('invalid value for "campaigns", campaigns cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @total.nil? + return false if @campaigns.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total == o.total && + campaigns == o.campaigns + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total, campaigns].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_referrals_campaigns_item.rb b/lib/VoucherifySdk/models/customer_referrals_campaigns_item.rb new file mode 100644 index 00000000..80602368 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_referrals_campaigns_item.rb @@ -0,0 +1,291 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the source of the referral. + class CustomerReferralsCampaignsItem + # Unique campaign ID, assigned by Voucherify. + attr_accessor :campaign_id + + # Unique referrer ID, assigned by Voucherify. This is the customer ID of a customer that is referring this customer. + attr_accessor :referrer_id + + # Related object id + attr_accessor :related_object_id + + # Related object type, i.e. `redemption`. + attr_accessor :related_object_type + + # Timestamp representing the date and time when the customer was referred in ISO 8601 format. + attr_accessor :date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'campaign_id' => :'campaign_id', + :'referrer_id' => :'referrer_id', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'date' => :'date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'campaign_id' => :'String', + :'referrer_id' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerReferralsCampaignsItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerReferralsCampaignsItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + else + self.referrer_id = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = nil + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + else + self.date = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @referrer_id.nil? + invalid_properties.push('invalid value for "referrer_id", referrer_id cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + if @date.nil? + invalid_properties.push('invalid value for "date", date cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @campaign_id.nil? + return false if @referrer_id.nil? + return false if @related_object_id.nil? + return false if @related_object_type.nil? + return false if @date.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + campaign_id == o.campaign_id && + referrer_id == o.referrer_id && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + date == o.date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [campaign_id, referrer_id, related_object_id, related_object_type, date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_response_data_assets.rb b/lib/VoucherifySdk/models/customer_response_data_assets.rb new file mode 100644 index 00000000..6d1f3774 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_response_data_assets.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the customer's cockpit. + class CustomerResponseDataAssets + # Customer's cockpit URL address. + attr_accessor :cockpit_url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'cockpit_url' => :'cockpit_url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'cockpit_url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerResponseDataAssets` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerResponseDataAssets`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'cockpit_url') + self.cockpit_url = attributes[:'cockpit_url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + cockpit_url == o.cockpit_url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [cockpit_url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_segments_list.rb b/lib/VoucherifySdk/models/customer_segments_list.rb new file mode 100644 index 00000000..110559bd --- /dev/null +++ b/lib/VoucherifySdk/models/customer_segments_list.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of customer's segments + class CustomerSegmentsList + # The type of object represented by JSON. This object stores information about customer segments. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of segment IDs. + attr_accessor :data_ref + + # A dictionary that contains an array of segment IDs and names. + attr_accessor :data + + # Total number of segments the customer belongs to. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerSegmentsList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerSegmentsList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_summary.rb b/lib/VoucherifySdk/models/customer_summary.rb new file mode 100644 index 00000000..d7854709 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_summary.rb @@ -0,0 +1,237 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomerSummary + attr_accessor :redemptions + + attr_accessor :orders + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redemptions' => :'redemptions', + :'orders' => :'orders' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redemptions' => :'CustomerSummaryRedemptions', + :'orders' => :'CustomerSummaryOrders' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerSummary` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerSummary`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redemptions') + self.redemptions = attributes[:'redemptions'] + else + self.redemptions = nil + end + + if attributes.key?(:'orders') + self.orders = attributes[:'orders'] + else + self.orders = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redemptions.nil? + invalid_properties.push('invalid value for "redemptions", redemptions cannot be nil.') + end + + if @orders.nil? + invalid_properties.push('invalid value for "orders", orders cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redemptions.nil? + return false if @orders.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redemptions == o.redemptions && + orders == o.orders + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redemptions, orders].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_summary_orders.rb b/lib/VoucherifySdk/models/customer_summary_orders.rb new file mode 100644 index 00000000..977f8daa --- /dev/null +++ b/lib/VoucherifySdk/models/customer_summary_orders.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomerSummaryOrders + # The total amount spent by the customer. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :total_amount + + # Total number of orders made by the customer. + attr_accessor :total_count + + # Average amount spent on orders. `total_amount` ÷ `total_count`. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :average_amount + + # Amount spent on last order. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :last_order_amount + + # Timestamp representing the date and time of the customer's last order in ISO 8601 format. + attr_accessor :last_order_date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total_amount' => :'total_amount', + :'total_count' => :'total_count', + :'average_amount' => :'average_amount', + :'last_order_amount' => :'last_order_amount', + :'last_order_date' => :'last_order_date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total_amount' => :'Integer', + :'total_count' => :'Integer', + :'average_amount' => :'Integer', + :'last_order_amount' => :'Integer', + :'last_order_date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerSummaryOrders` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerSummaryOrders`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + else + self.total_amount = nil + end + + if attributes.key?(:'total_count') + self.total_count = attributes[:'total_count'] + else + self.total_count = nil + end + + if attributes.key?(:'average_amount') + self.average_amount = attributes[:'average_amount'] + else + self.average_amount = nil + end + + if attributes.key?(:'last_order_amount') + self.last_order_amount = attributes[:'last_order_amount'] + else + self.last_order_amount = nil + end + + if attributes.key?(:'last_order_date') + self.last_order_date = attributes[:'last_order_date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @total_amount.nil? + invalid_properties.push('invalid value for "total_amount", total_amount cannot be nil.') + end + + if @total_count.nil? + invalid_properties.push('invalid value for "total_count", total_count cannot be nil.') + end + + if @average_amount.nil? + invalid_properties.push('invalid value for "average_amount", average_amount cannot be nil.') + end + + if @last_order_amount.nil? + invalid_properties.push('invalid value for "last_order_amount", last_order_amount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @total_amount.nil? + return false if @total_count.nil? + return false if @average_amount.nil? + return false if @last_order_amount.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_amount == o.total_amount && + total_count == o.total_count && + average_amount == o.average_amount && + last_order_amount == o.last_order_amount && + last_order_date == o.last_order_date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total_amount, total_count, average_amount, last_order_amount, last_order_date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_summary_redemptions.rb b/lib/VoucherifySdk/models/customer_summary_redemptions.rb new file mode 100644 index 00000000..af756195 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_summary_redemptions.rb @@ -0,0 +1,339 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomerSummaryRedemptions + # Total number of redemptions made by the customer. + attr_accessor :total_redeemed + + # Total number of redemptions that failed. + attr_accessor :total_failed + + # Total number of redemptions that succeeded. + attr_accessor :total_succeeded + + # Total number of redemptions that were rolled back for the customer. + attr_accessor :total_rolled_back + + # Total number of redemption rollbacks that failed. + attr_accessor :total_rollback_failed + + # Total number of redemption rollbacks that succeeded. + attr_accessor :total_rollback_succeeded + + attr_accessor :gift + + attr_accessor :loyalty_card + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total_redeemed' => :'total_redeemed', + :'total_failed' => :'total_failed', + :'total_succeeded' => :'total_succeeded', + :'total_rolled_back' => :'total_rolled_back', + :'total_rollback_failed' => :'total_rollback_failed', + :'total_rollback_succeeded' => :'total_rollback_succeeded', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total_redeemed' => :'Integer', + :'total_failed' => :'Integer', + :'total_succeeded' => :'Integer', + :'total_rolled_back' => :'Integer', + :'total_rollback_failed' => :'Integer', + :'total_rollback_succeeded' => :'Integer', + :'gift' => :'CustomerSummaryRedemptionsGift', + :'loyalty_card' => :'CustomerSummaryRedemptionsLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerSummaryRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerSummaryRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total_redeemed') + self.total_redeemed = attributes[:'total_redeemed'] + else + self.total_redeemed = nil + end + + if attributes.key?(:'total_failed') + self.total_failed = attributes[:'total_failed'] + else + self.total_failed = nil + end + + if attributes.key?(:'total_succeeded') + self.total_succeeded = attributes[:'total_succeeded'] + else + self.total_succeeded = nil + end + + if attributes.key?(:'total_rolled_back') + self.total_rolled_back = attributes[:'total_rolled_back'] + else + self.total_rolled_back = nil + end + + if attributes.key?(:'total_rollback_failed') + self.total_rollback_failed = attributes[:'total_rollback_failed'] + else + self.total_rollback_failed = nil + end + + if attributes.key?(:'total_rollback_succeeded') + self.total_rollback_succeeded = attributes[:'total_rollback_succeeded'] + else + self.total_rollback_succeeded = nil + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + else + self.gift = nil + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + else + self.loyalty_card = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @total_redeemed.nil? + invalid_properties.push('invalid value for "total_redeemed", total_redeemed cannot be nil.') + end + + if @total_failed.nil? + invalid_properties.push('invalid value for "total_failed", total_failed cannot be nil.') + end + + if @total_succeeded.nil? + invalid_properties.push('invalid value for "total_succeeded", total_succeeded cannot be nil.') + end + + if @total_rolled_back.nil? + invalid_properties.push('invalid value for "total_rolled_back", total_rolled_back cannot be nil.') + end + + if @total_rollback_failed.nil? + invalid_properties.push('invalid value for "total_rollback_failed", total_rollback_failed cannot be nil.') + end + + if @total_rollback_succeeded.nil? + invalid_properties.push('invalid value for "total_rollback_succeeded", total_rollback_succeeded cannot be nil.') + end + + if @gift.nil? + invalid_properties.push('invalid value for "gift", gift cannot be nil.') + end + + if @loyalty_card.nil? + invalid_properties.push('invalid value for "loyalty_card", loyalty_card cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @total_redeemed.nil? + return false if @total_failed.nil? + return false if @total_succeeded.nil? + return false if @total_rolled_back.nil? + return false if @total_rollback_failed.nil? + return false if @total_rollback_succeeded.nil? + return false if @gift.nil? + return false if @loyalty_card.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_redeemed == o.total_redeemed && + total_failed == o.total_failed && + total_succeeded == o.total_succeeded && + total_rolled_back == o.total_rolled_back && + total_rollback_failed == o.total_rollback_failed && + total_rollback_succeeded == o.total_rollback_succeeded && + gift == o.gift && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total_redeemed, total_failed, total_succeeded, total_rolled_back, total_rollback_failed, total_rollback_succeeded, gift, loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_summary_redemptions_gift.rb b/lib/VoucherifySdk/models/customer_summary_redemptions_gift.rb new file mode 100644 index 00000000..22dc0fb0 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_summary_redemptions_gift.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Summary of gift card credits. + class CustomerSummaryRedemptionsGift + # Total amount of gift card credits redeemed by customer. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :redeemed_amount + + # Remaining gift card balance across all gift cards. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :amount_to_go + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemed_amount' => :'redeemed_amount', + :'amount_to_go' => :'amount_to_go' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemed_amount' => :'Integer', + :'amount_to_go' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerSummaryRedemptionsGift` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerSummaryRedemptionsGift`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemed_amount') + self.redeemed_amount = attributes[:'redeemed_amount'] + else + self.redeemed_amount = 0 + end + + if attributes.key?(:'amount_to_go') + self.amount_to_go = attributes[:'amount_to_go'] + else + self.amount_to_go = 0 + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemed_amount.nil? + invalid_properties.push('invalid value for "redeemed_amount", redeemed_amount cannot be nil.') + end + + if @amount_to_go.nil? + invalid_properties.push('invalid value for "amount_to_go", amount_to_go cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemed_amount.nil? + return false if @amount_to_go.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemed_amount == o.redeemed_amount && + amount_to_go == o.amount_to_go + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemed_amount, amount_to_go].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_summary_redemptions_loyalty_card.rb b/lib/VoucherifySdk/models/customer_summary_redemptions_loyalty_card.rb new file mode 100644 index 00000000..3721e599 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_summary_redemptions_loyalty_card.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Summary of loyalty points. + class CustomerSummaryRedemptionsLoyaltyCard + # Total number of loyalty points redeemed by the customer. + attr_accessor :redeemed_points + + # Sum of remaining available point balance across all loyalty cards. + attr_accessor :points_to_go + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemed_points' => :'redeemed_points', + :'points_to_go' => :'points_to_go' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemed_points' => :'Integer', + :'points_to_go' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerSummaryRedemptionsLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerSummaryRedemptionsLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemed_points') + self.redeemed_points = attributes[:'redeemed_points'] + else + self.redeemed_points = nil + end + + if attributes.key?(:'points_to_go') + self.points_to_go = attributes[:'points_to_go'] + else + self.points_to_go = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemed_points.nil? + invalid_properties.push('invalid value for "redeemed_points", redeemed_points cannot be nil.') + end + + if @points_to_go.nil? + invalid_properties.push('invalid value for "points_to_go", points_to_go cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemed_points.nil? + return false if @points_to_go.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemed_points == o.redeemed_points && + points_to_go == o.points_to_go + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemed_points, points_to_go].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customer_with_summary_loyalty_referrals.rb b/lib/VoucherifySdk/models/customer_with_summary_loyalty_referrals.rb new file mode 100644 index 00000000..e109c046 --- /dev/null +++ b/lib/VoucherifySdk/models/customer_with_summary_loyalty_referrals.rb @@ -0,0 +1,438 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class CustomerWithSummaryLoyaltyReferrals + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # The ID of an existing customer that will be linked to redemption in this request. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + attr_accessor :summary + + attr_accessor :loyalty + + attr_accessor :referrals + + # Object used to store system metadata information. + attr_accessor :system_metadata + + # Timestamp representing the date and time when the customer was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the customer was updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :assets + + # The type of object represented by JSON. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata', + :'id' => :'id', + :'source_id' => :'source_id', + :'summary' => :'summary', + :'loyalty' => :'loyalty', + :'referrals' => :'referrals', + :'system_metadata' => :'system_metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assets' => :'assets', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object', + :'id' => :'String', + :'source_id' => :'String', + :'summary' => :'CustomerSummary', + :'loyalty' => :'CustomerLoyalty', + :'referrals' => :'CustomerReferrals', + :'system_metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assets' => :'CustomerResponseDataAssets', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'address', + :'summary', + :'loyalty', + :'referrals', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomerWithSummaryLoyaltyReferrals` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomerWithSummaryLoyaltyReferrals`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + else + self.summary = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'referrals') + self.referrals = attributes[:'referrals'] + else + self.referrals = nil + end + + if attributes.key?(:'system_metadata') + self.system_metadata = attributes[:'system_metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata && + id == o.id && + source_id == o.source_id && + summary == o.summary && + loyalty == o.loyalty && + referrals == o.referrals && + system_metadata == o.system_metadata && + created_at == o.created_at && + updated_at == o.updated_at && + assets == o.assets && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, email, phone, birthday, birthdate, address, metadata, id, source_id, summary, loyalty, referrals, system_metadata, created_at, updated_at, assets, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_activities_list_response_body.rb b/lib/VoucherifySdk/models/customers_activities_list_response_body.rb new file mode 100644 index 00000000..7ac3d90f --- /dev/null +++ b/lib/VoucherifySdk/models/customers_activities_list_response_body.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **GET** `/customers/{customerId}/activities`. + class CustomersActivitiesListResponseBody + # The type of object represented by JSON. This object stores information about customer activities in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of customer activity objects. + attr_accessor :data_ref + + # Array of customer activity objects. + attr_accessor :data + + # Total number of customer activities. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersActivitiesListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersActivitiesListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_create_request_body.rb b/lib/VoucherifySdk/models/customers_create_request_body.rb new file mode 100644 index 00000000..e1db62b7 --- /dev/null +++ b/lib/VoucherifySdk/models/customers_create_request_body.rb @@ -0,0 +1,313 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/customers`. + class CustomersCreateRequestBody + # The ID of an existing customer. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Customer' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_create_response_body.rb b/lib/VoucherifySdk/models/customers_create_response_body.rb new file mode 100644 index 00000000..2c788c2a --- /dev/null +++ b/lib/VoucherifySdk/models/customers_create_response_body.rb @@ -0,0 +1,439 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response bofy for **POST** `/customers`. + class CustomersCreateResponseBody + # The ID of an existing customer that will be linked to redemption in this request. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + attr_accessor :summary + + attr_accessor :loyalty + + attr_accessor :referrals + + # Object used to store system metadata information. + attr_accessor :system_metadata + + # Timestamp representing the date and time when the customer was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the customer was updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :assets + + # The type of object represented by JSON. + attr_accessor :object + + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'summary' => :'summary', + :'loyalty' => :'loyalty', + :'referrals' => :'referrals', + :'system_metadata' => :'system_metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assets' => :'assets', + :'object' => :'object', + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'summary' => :'CustomerSummary', + :'loyalty' => :'CustomerLoyalty', + :'referrals' => :'CustomerReferrals', + :'system_metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assets' => :'CustomerResponseDataAssets', + :'object' => :'String', + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'summary', + :'loyalty', + :'referrals', + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerWithSummaryLoyaltyReferrals' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + else + self.summary = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'referrals') + self.referrals = attributes[:'referrals'] + else + self.referrals = nil + end + + if attributes.key?(:'system_metadata') + self.system_metadata = attributes[:'system_metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + summary == o.summary && + loyalty == o.loyalty && + referrals == o.referrals && + system_metadata == o.system_metadata && + created_at == o.created_at && + updated_at == o.updated_at && + assets == o.assets && + object == o.object && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, summary, loyalty, referrals, system_metadata, created_at, updated_at, assets, object, name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_get_response_body.rb b/lib/VoucherifySdk/models/customers_get_response_body.rb new file mode 100644 index 00000000..d31106de --- /dev/null +++ b/lib/VoucherifySdk/models/customers_get_response_body.rb @@ -0,0 +1,439 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/customers/{customerId}`. + class CustomersGetResponseBody + # The ID of an existing customer that will be linked to redemption in this request. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + attr_accessor :summary + + attr_accessor :loyalty + + attr_accessor :referrals + + # Object used to store system metadata information. + attr_accessor :system_metadata + + # Timestamp representing the date and time when the customer was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the customer was updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :assets + + # The type of object represented by JSON. + attr_accessor :object + + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'summary' => :'summary', + :'loyalty' => :'loyalty', + :'referrals' => :'referrals', + :'system_metadata' => :'system_metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assets' => :'assets', + :'object' => :'object', + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'summary' => :'CustomerSummary', + :'loyalty' => :'CustomerLoyalty', + :'referrals' => :'CustomerReferrals', + :'system_metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assets' => :'CustomerResponseDataAssets', + :'object' => :'String', + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'summary', + :'loyalty', + :'referrals', + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerWithSummaryLoyaltyReferrals' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + else + self.summary = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'referrals') + self.referrals = attributes[:'referrals'] + else + self.referrals = nil + end + + if attributes.key?(:'system_metadata') + self.system_metadata = attributes[:'system_metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + summary == o.summary && + loyalty == o.loyalty && + referrals == o.referrals && + system_metadata == o.system_metadata && + created_at == o.created_at && + updated_at == o.updated_at && + assets == o.assets && + object == o.object && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, summary, loyalty, referrals, system_metadata, created_at, updated_at, assets, object, name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_import_csv_create_response_body.rb b/lib/VoucherifySdk/models/customers_import_csv_create_response_body.rb new file mode 100644 index 00000000..b3944e4a --- /dev/null +++ b/lib/VoucherifySdk/models/customers_import_csv_create_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/customers/importCSV`. + class CustomersImportCsvCreateResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersImportCsvCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersImportCsvCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_list_response_body.rb b/lib/VoucherifySdk/models/customers_list_response_body.rb new file mode 100644 index 00000000..05932ac5 --- /dev/null +++ b/lib/VoucherifySdk/models/customers_list_response_body.rb @@ -0,0 +1,286 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/customers`. + class CustomersListResponseBody + # The type of object represented by JSON. This object stores information about customers in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of customer objects. + attr_accessor :data_ref + + # Contains array of customer objects. + attr_accessor :customers + + # Total number of customers. + attr_accessor :total + + # As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different end date filter) to get more records returned in the results. + attr_accessor :has_more + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'customers' => :'customers', + :'total' => :'total', + :'has_more' => :'has_more' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'customers' => :'Array', + :'total' => :'Integer', + :'has_more' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'customers' + end + + if attributes.key?(:'customers') + if (value = attributes[:'customers']).is_a?(Array) + self.customers = value + end + else + self.customers = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @customers.nil? + invalid_properties.push('invalid value for "customers", customers cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @customers.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + customers == o.customers && + total == o.total && + has_more == o.has_more + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, customers, total, has_more].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_metadata_update_in_bulk_request_body.rb b/lib/VoucherifySdk/models/customers_metadata_update_in_bulk_request_body.rb new file mode 100644 index 00000000..0217cac4 --- /dev/null +++ b/lib/VoucherifySdk/models/customers_metadata_update_in_bulk_request_body.rb @@ -0,0 +1,242 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/customers/metadata/async`. + class CustomersMetadataUpdateInBulkRequestBody + # An array of customer `source_id`'s. + attr_accessor :source_ids + + # Metadata key value pairs to be updated. A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'source_ids' => :'source_ids', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'source_ids' => :'Array', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersMetadataUpdateInBulkRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersMetadataUpdateInBulkRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'source_ids') + if (value = attributes[:'source_ids']).is_a?(Array) + self.source_ids = value + end + else + self.source_ids = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @source_ids.nil? + invalid_properties.push('invalid value for "source_ids", source_ids cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @source_ids.nil? + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + source_ids == o.source_ids && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [source_ids, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_metadata_update_in_bulk_response_body.rb b/lib/VoucherifySdk/models/customers_metadata_update_in_bulk_response_body.rb new file mode 100644 index 00000000..4dc462d8 --- /dev/null +++ b/lib/VoucherifySdk/models/customers_metadata_update_in_bulk_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/customers/metadata/async`. + class CustomersMetadataUpdateInBulkResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersMetadataUpdateInBulkResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersMetadataUpdateInBulkResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_permanent_deletion_create_response_body.rb b/lib/VoucherifySdk/models/customers_permanent_deletion_create_response_body.rb new file mode 100644 index 00000000..8aa4fe05 --- /dev/null +++ b/lib/VoucherifySdk/models/customers_permanent_deletion_create_response_body.rb @@ -0,0 +1,324 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/customers/{customerId}/permanent-deletion`. + class CustomersPermanentDeletionCreateResponseBody + # Unique permanent deletion object ID. + attr_accessor :id + + # Timestamp representing the date and time when the customer was requested to be deleted in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID that is being deleted. + attr_accessor :related_object_id + + # Object being deleted. + attr_accessor :related_object + + # Deletion status. + attr_accessor :status + + attr_accessor :data_json + + # The type of object represented by JSON. + attr_accessor :object + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'related_object_id' => :'related_object_id', + :'related_object' => :'related_object', + :'status' => :'status', + :'data_json' => :'data_json', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'related_object_id' => :'String', + :'related_object' => :'String', + :'status' => :'String', + :'data_json' => :'CustomersPermanentDeletionCreateResponseBodyDataJson', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersPermanentDeletionCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersPermanentDeletionCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object') + self.related_object = attributes[:'related_object'] + else + self.related_object = 'customer' + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'DONE' + end + + if attributes.key?(:'data_json') + self.data_json = attributes[:'data_json'] + else + self.data_json = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'pernament_deletion' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object.nil? + invalid_properties.push('invalid value for "related_object", related_object cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @data_json.nil? + invalid_properties.push('invalid value for "data_json", data_json cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @created_at.nil? + return false if @related_object_id.nil? + return false if @related_object.nil? + return false if @status.nil? + return false if @data_json.nil? + return false if @object.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + related_object_id == o.related_object_id && + related_object == o.related_object && + status == o.status && + data_json == o.data_json && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, related_object_id, related_object, status, data_json, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_permanent_deletion_create_response_body_data_json.rb b/lib/VoucherifySdk/models/customers_permanent_deletion_create_response_body_data_json.rb new file mode 100644 index 00000000..0d6f15fa --- /dev/null +++ b/lib/VoucherifySdk/models/customers_permanent_deletion_create_response_body_data_json.rb @@ -0,0 +1,325 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Statistics summarizing the number of related information that was deleted. + class CustomersPermanentDeletionCreateResponseBodyDataJson + # Number of events deleted. + attr_accessor :events + + # Number of customer events deleted. + attr_accessor :customer_events + + # Number of daily events deleted. + attr_accessor :daily_events + + # Number of segments deleted. + attr_accessor :segments + + # Number of orders deleted. + attr_accessor :orders + + # Number of order events deleted. + attr_accessor :order_events + + # Number of customers deleted. + attr_accessor :customer + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'events' => :'events', + :'customer_events' => :'customer_events', + :'daily_events' => :'daily_events', + :'segments' => :'segments', + :'orders' => :'orders', + :'order_events' => :'order_events', + :'customer' => :'customer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'events' => :'Integer', + :'customer_events' => :'Integer', + :'daily_events' => :'Integer', + :'segments' => :'Integer', + :'orders' => :'Integer', + :'order_events' => :'Integer', + :'customer' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersPermanentDeletionCreateResponseBodyDataJson` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersPermanentDeletionCreateResponseBodyDataJson`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'events') + self.events = attributes[:'events'] + else + self.events = nil + end + + if attributes.key?(:'customer_events') + self.customer_events = attributes[:'customer_events'] + else + self.customer_events = nil + end + + if attributes.key?(:'daily_events') + self.daily_events = attributes[:'daily_events'] + else + self.daily_events = nil + end + + if attributes.key?(:'segments') + self.segments = attributes[:'segments'] + else + self.segments = nil + end + + if attributes.key?(:'orders') + self.orders = attributes[:'orders'] + else + self.orders = nil + end + + if attributes.key?(:'order_events') + self.order_events = attributes[:'order_events'] + else + self.order_events = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = 1 + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @events.nil? + invalid_properties.push('invalid value for "events", events cannot be nil.') + end + + if @customer_events.nil? + invalid_properties.push('invalid value for "customer_events", customer_events cannot be nil.') + end + + if @daily_events.nil? + invalid_properties.push('invalid value for "daily_events", daily_events cannot be nil.') + end + + if @segments.nil? + invalid_properties.push('invalid value for "segments", segments cannot be nil.') + end + + if @orders.nil? + invalid_properties.push('invalid value for "orders", orders cannot be nil.') + end + + if @order_events.nil? + invalid_properties.push('invalid value for "order_events", order_events cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @events.nil? + return false if @customer_events.nil? + return false if @daily_events.nil? + return false if @segments.nil? + return false if @orders.nil? + return false if @order_events.nil? + return false if @customer.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + events == o.events && + customer_events == o.customer_events && + daily_events == o.daily_events && + segments == o.segments && + orders == o.orders && + order_events == o.order_events && + customer == o.customer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [events, customer_events, daily_events, segments, orders, order_events, customer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_segments_list_response_body.rb b/lib/VoucherifySdk/models/customers_segments_list_response_body.rb new file mode 100644 index 00000000..c13f91ba --- /dev/null +++ b/lib/VoucherifySdk/models/customers_segments_list_response_body.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/customers/{customerId}/segments`. + class CustomersSegmentsListResponseBody + # The type of object represented by JSON. This object stores information about customer segments. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of segment IDs. + attr_accessor :data_ref + + # A dictionary that contains an array of segment IDs and names. + attr_accessor :data + + # Total number of segments the customer belongs to. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerSegmentsList' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersSegmentsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersSegmentsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_update_in_bulk_request_body.rb b/lib/VoucherifySdk/models/customers_update_in_bulk_request_body.rb new file mode 100644 index 00000000..401db8fe --- /dev/null +++ b/lib/VoucherifySdk/models/customers_update_in_bulk_request_body.rb @@ -0,0 +1,310 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/customers/bulk/async`. + class CustomersUpdateInBulkRequestBody + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # Unique customer source ID. + attr_accessor :source_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata', + :'source_id' => :'source_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object', + :'source_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersUpdateInBulkRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersUpdateInBulkRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @source_id.nil? + invalid_properties.push('invalid value for "source_id", source_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @source_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata && + source_id == o.source_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, email, phone, birthday, birthdate, address, metadata, source_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_update_in_bulk_response_body.rb b/lib/VoucherifySdk/models/customers_update_in_bulk_response_body.rb new file mode 100644 index 00000000..da5a3a8d --- /dev/null +++ b/lib/VoucherifySdk/models/customers_update_in_bulk_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/customers/bulk/async`. + class CustomersUpdateInBulkResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersUpdateInBulkResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersUpdateInBulkResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_update_request_body.rb b/lib/VoucherifySdk/models/customers_update_request_body.rb new file mode 100644 index 00000000..7f1a8a29 --- /dev/null +++ b/lib/VoucherifySdk/models/customers_update_request_body.rb @@ -0,0 +1,293 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **PUT** `/customers/{customerId}`. + class CustomersUpdateRequestBody + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/customers_update_response_body.rb b/lib/VoucherifySdk/models/customers_update_response_body.rb new file mode 100644 index 00000000..9805eccb --- /dev/null +++ b/lib/VoucherifySdk/models/customers_update_response_body.rb @@ -0,0 +1,439 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/customers/{customerId}`. + class CustomersUpdateResponseBody + # The ID of an existing customer that will be linked to redemption in this request. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + attr_accessor :summary + + attr_accessor :loyalty + + attr_accessor :referrals + + # Object used to store system metadata information. + attr_accessor :system_metadata + + # Timestamp representing the date and time when the customer was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the customer was updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :assets + + # The type of object represented by JSON. + attr_accessor :object + + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'summary' => :'summary', + :'loyalty' => :'loyalty', + :'referrals' => :'referrals', + :'system_metadata' => :'system_metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assets' => :'assets', + :'object' => :'object', + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'summary' => :'CustomerSummary', + :'loyalty' => :'CustomerLoyalty', + :'referrals' => :'CustomerReferrals', + :'system_metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assets' => :'CustomerResponseDataAssets', + :'object' => :'String', + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'summary', + :'loyalty', + :'referrals', + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerWithSummaryLoyaltyReferrals' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::CustomersUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::CustomersUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + else + self.summary = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'referrals') + self.referrals = attributes[:'referrals'] + else + self.referrals = nil + end + + if attributes.key?(:'system_metadata') + self.system_metadata = attributes[:'system_metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + summary == o.summary && + loyalty == o.loyalty && + referrals == o.referrals && + system_metadata == o.system_metadata && + created_at == o.created_at && + updated_at == o.updated_at && + assets == o.assets && + object == o.object && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, summary, loyalty, referrals, system_metadata, created_at, updated_at, assets, object, name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount.rb b/lib/VoucherifySdk/models/discount.rb new file mode 100644 index 00000000..9fa62de6 --- /dev/null +++ b/lib/VoucherifySdk/models/discount.rb @@ -0,0 +1,109 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about discount. + module Discount + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'DiscountAmount', + :'DiscountFixed', + :'DiscountPercent', + :'DiscountUnit', + :'DiscountUnitMultiple' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/discount_amount.rb b/lib/VoucherifySdk/models/discount_amount.rb new file mode 100644 index 00000000..ea7d343b --- /dev/null +++ b/lib/VoucherifySdk/models/discount_amount.rb @@ -0,0 +1,311 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountAmount + # Defines the type of the voucher. + attr_accessor :type + + # Amount taken off the subtotal of a price. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 discount is written as 1000. + attr_accessor :amount_off + + attr_accessor :amount_off_formula + + # Maximum discount amount per order. + attr_accessor :aggregated_amount_limit + + attr_accessor :effect + + # Flag indicating whether the discount was calculated using a formula. + attr_accessor :is_dynamic + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'amount_off' => :'amount_off', + :'amount_off_formula' => :'amount_off_formula', + :'aggregated_amount_limit' => :'aggregated_amount_limit', + :'effect' => :'effect', + :'is_dynamic' => :'is_dynamic' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'amount_off' => :'Float', + :'amount_off_formula' => :'String', + :'aggregated_amount_limit' => :'Integer', + :'effect' => :'DiscountAmountVouchersEffectTypes', + :'is_dynamic' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::DiscountAmount` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::DiscountAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'AMOUNT' + end + + if attributes.key?(:'amount_off') + self.amount_off = attributes[:'amount_off'] + else + self.amount_off = nil + end + + if attributes.key?(:'amount_off_formula') + self.amount_off_formula = attributes[:'amount_off_formula'] + end + + if attributes.key?(:'aggregated_amount_limit') + self.aggregated_amount_limit = attributes[:'aggregated_amount_limit'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + end + + if attributes.key?(:'is_dynamic') + self.is_dynamic = attributes[:'is_dynamic'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @amount_off.nil? + invalid_properties.push('invalid value for "amount_off", amount_off cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["AMOUNT", "UNIT", "PERCENT", "FIXED"]) + return false unless type_validator.valid?(@type) + return false if @amount_off.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AMOUNT", "UNIT", "PERCENT", "FIXED"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + amount_off == o.amount_off && + amount_off_formula == o.amount_off_formula && + aggregated_amount_limit == o.aggregated_amount_limit && + effect == o.effect && + is_dynamic == o.is_dynamic + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, amount_off, amount_off_formula, aggregated_amount_limit, effect, is_dynamic].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount_amount_vouchers_effect_types.rb b/lib/VoucherifySdk/models/discount_amount_vouchers_effect_types.rb new file mode 100644 index 00000000..f4be327e --- /dev/null +++ b/lib/VoucherifySdk/models/discount_amount_vouchers_effect_types.rb @@ -0,0 +1,43 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountAmountVouchersEffectTypes + ORDER = "APPLY_TO_ORDER".freeze + ITEMS = "APPLY_TO_ITEMS".freeze + ITEMS_PROPORTIONALLY = "APPLY_TO_ITEMS_PROPORTIONALLY".freeze + ITEMS_PROPORTIONALLY_BY_QUANTITY = "APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY".freeze + ITEMS_BY_QUANTITY = "APPLY_TO_ITEMS_BY_QUANTITY".freeze + + def self.all_vars + @all_vars ||= [ORDER, ITEMS, ITEMS_PROPORTIONALLY, ITEMS_PROPORTIONALLY_BY_QUANTITY, ITEMS_BY_QUANTITY].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if DiscountAmountVouchersEffectTypes.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #DiscountAmountVouchersEffectTypes" + end + end +end diff --git a/lib/VoucherifySdk/models/discount_coupons_campaign_voucher.rb b/lib/VoucherifySdk/models/discount_coupons_campaign_voucher.rb new file mode 100644 index 00000000..4f8e7d91 --- /dev/null +++ b/lib/VoucherifySdk/models/discount_coupons_campaign_voucher.rb @@ -0,0 +1,290 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountCouponsCampaignVoucher + # Type of voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :code_config + + attr_accessor :redemption + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'discount' => :'discount', + :'code_config' => :'code_config', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'discount' => :'Discount', + :'code_config' => :'CodeConfig', + :'redemption' => :'CampaignLoyaltyVoucherRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::DiscountCouponsCampaignVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::DiscountCouponsCampaignVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'DISCOUNT_VOUCHER' + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + else + self.discount = nil + end + + if attributes.key?(:'code_config') + self.code_config = attributes[:'code_config'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @discount.nil? + invalid_properties.push('invalid value for "discount", discount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER"]) + return false unless type_validator.valid?(@type) + return false if @discount.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + discount == o.discount && + code_config == o.code_config && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, discount, code_config, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount_fixed.rb b/lib/VoucherifySdk/models/discount_fixed.rb new file mode 100644 index 00000000..e0f9ddc1 --- /dev/null +++ b/lib/VoucherifySdk/models/discount_fixed.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountFixed + # Defines the type of the voucher. + attr_accessor :type + + # Sets a fixed value for an order total or the item price. The value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 discount is written as 1000. If the fixed amount is calculated by the formula, i.e. the `fixed_amount_formula` parameter is present in the fixed amount definition, this value becomes the **fallback value**. As a result, if the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed value. + attr_accessor :fixed_amount + + attr_accessor :fixed_amount_formula + + attr_accessor :effect + + # Flag indicating whether the discount was calculated using a formula. + attr_accessor :is_dynamic + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'fixed_amount' => :'fixed_amount', + :'fixed_amount_formula' => :'fixed_amount_formula', + :'effect' => :'effect', + :'is_dynamic' => :'is_dynamic' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'fixed_amount' => :'Float', + :'fixed_amount_formula' => :'String', + :'effect' => :'DiscountFixedVouchersEffectTypes', + :'is_dynamic' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::DiscountFixed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::DiscountFixed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'FIXED' + end + + if attributes.key?(:'fixed_amount') + self.fixed_amount = attributes[:'fixed_amount'] + else + self.fixed_amount = nil + end + + if attributes.key?(:'fixed_amount_formula') + self.fixed_amount_formula = attributes[:'fixed_amount_formula'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + end + + if attributes.key?(:'is_dynamic') + self.is_dynamic = attributes[:'is_dynamic'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @fixed_amount.nil? + invalid_properties.push('invalid value for "fixed_amount", fixed_amount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["FIXED"]) + return false unless type_validator.valid?(@type) + return false if @fixed_amount.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["FIXED"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + fixed_amount == o.fixed_amount && + fixed_amount_formula == o.fixed_amount_formula && + effect == o.effect && + is_dynamic == o.is_dynamic + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, fixed_amount, fixed_amount_formula, effect, is_dynamic].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount_fixed_vouchers_effect_types.rb b/lib/VoucherifySdk/models/discount_fixed_vouchers_effect_types.rb new file mode 100644 index 00000000..7794af00 --- /dev/null +++ b/lib/VoucherifySdk/models/discount_fixed_vouchers_effect_types.rb @@ -0,0 +1,40 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountFixedVouchersEffectTypes + ORDER = "APPLY_TO_ORDER".freeze + ITEMS = "APPLY_TO_ITEMS".freeze + + def self.all_vars + @all_vars ||= [ORDER, ITEMS].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if DiscountFixedVouchersEffectTypes.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #DiscountFixedVouchersEffectTypes" + end + end +end diff --git a/lib/VoucherifySdk/models/discount_percent.rb b/lib/VoucherifySdk/models/discount_percent.rb new file mode 100644 index 00000000..fdc79422 --- /dev/null +++ b/lib/VoucherifySdk/models/discount_percent.rb @@ -0,0 +1,321 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountPercent + # Defines the type of the voucher. + attr_accessor :type + + # The percent discount that the customer will receive. + attr_accessor :percent_off + + attr_accessor :percent_off_formula + + # Upper limit allowed to be applied as a discount. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600. + attr_accessor :amount_limit + + # Maximum discount amount per order. + attr_accessor :aggregated_amount_limit + + attr_accessor :effect + + # Flag indicating whether the discount was calculated using a formula. + attr_accessor :is_dynamic + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'percent_off' => :'percent_off', + :'percent_off_formula' => :'percent_off_formula', + :'amount_limit' => :'amount_limit', + :'aggregated_amount_limit' => :'aggregated_amount_limit', + :'effect' => :'effect', + :'is_dynamic' => :'is_dynamic' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'percent_off' => :'Float', + :'percent_off_formula' => :'String', + :'amount_limit' => :'Float', + :'aggregated_amount_limit' => :'Integer', + :'effect' => :'DiscountPercentVouchersEffectTypes', + :'is_dynamic' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::DiscountPercent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::DiscountPercent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PERCENT' + end + + if attributes.key?(:'percent_off') + self.percent_off = attributes[:'percent_off'] + else + self.percent_off = nil + end + + if attributes.key?(:'percent_off_formula') + self.percent_off_formula = attributes[:'percent_off_formula'] + end + + if attributes.key?(:'amount_limit') + self.amount_limit = attributes[:'amount_limit'] + end + + if attributes.key?(:'aggregated_amount_limit') + self.aggregated_amount_limit = attributes[:'aggregated_amount_limit'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + end + + if attributes.key?(:'is_dynamic') + self.is_dynamic = attributes[:'is_dynamic'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @percent_off.nil? + invalid_properties.push('invalid value for "percent_off", percent_off cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PERCENT"]) + return false unless type_validator.valid?(@type) + return false if @percent_off.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PERCENT"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + percent_off == o.percent_off && + percent_off_formula == o.percent_off_formula && + amount_limit == o.amount_limit && + aggregated_amount_limit == o.aggregated_amount_limit && + effect == o.effect && + is_dynamic == o.is_dynamic + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, percent_off, percent_off_formula, amount_limit, aggregated_amount_limit, effect, is_dynamic].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount_percent_vouchers_effect_types.rb b/lib/VoucherifySdk/models/discount_percent_vouchers_effect_types.rb new file mode 100644 index 00000000..e6b466fe --- /dev/null +++ b/lib/VoucherifySdk/models/discount_percent_vouchers_effect_types.rb @@ -0,0 +1,40 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountPercentVouchersEffectTypes + ORDER = "APPLY_TO_ORDER".freeze + ITEMS = "APPLY_TO_ITEMS".freeze + + def self.all_vars + @all_vars ||= [ORDER, ITEMS].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if DiscountPercentVouchersEffectTypes.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #DiscountPercentVouchersEffectTypes" + end + end +end diff --git a/lib/VoucherifySdk/models/discount_unit.rb b/lib/VoucherifySdk/models/discount_unit.rb new file mode 100644 index 00000000..dd58916e --- /dev/null +++ b/lib/VoucherifySdk/models/discount_unit.rb @@ -0,0 +1,329 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountUnit + # Discount type. + attr_accessor :type + + # Number of units to be granted a full value discount. + attr_accessor :unit_off + + attr_accessor :unit_off_formula + + attr_accessor :effect + + # The product deemed as free, chosen from product inventory (e.g. time, items). + attr_accessor :unit_type + + attr_accessor :product + + attr_accessor :sku + + # Flag indicating whether the discount was calculated using a formula. + attr_accessor :is_dynamic + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'unit_off' => :'unit_off', + :'unit_off_formula' => :'unit_off_formula', + :'effect' => :'effect', + :'unit_type' => :'unit_type', + :'product' => :'product', + :'sku' => :'sku', + :'is_dynamic' => :'is_dynamic' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'unit_off' => :'Integer', + :'unit_off_formula' => :'String', + :'effect' => :'DiscountUnitVouchersEffectTypes', + :'unit_type' => :'String', + :'product' => :'SimpleProductDiscountUnit', + :'sku' => :'SimpleSkuDiscountUnit', + :'is_dynamic' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::DiscountUnit` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::DiscountUnit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'UNIT' + end + + if attributes.key?(:'unit_off') + self.unit_off = attributes[:'unit_off'] + end + + if attributes.key?(:'unit_off_formula') + self.unit_off_formula = attributes[:'unit_off_formula'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + end + + if attributes.key?(:'unit_type') + self.unit_type = attributes[:'unit_type'] + else + self.unit_type = nil + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + + if attributes.key?(:'is_dynamic') + self.is_dynamic = attributes[:'is_dynamic'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @unit_type.nil? + invalid_properties.push('invalid value for "unit_type", unit_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["UNIT"]) + return false unless type_validator.valid?(@type) + return false if @unit_type.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["UNIT"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + unit_off == o.unit_off && + unit_off_formula == o.unit_off_formula && + effect == o.effect && + unit_type == o.unit_type && + product == o.product && + sku == o.sku && + is_dynamic == o.is_dynamic + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, unit_off, unit_off_formula, effect, unit_type, product, sku, is_dynamic].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount_unit_multiple.rb b/lib/VoucherifySdk/models/discount_unit_multiple.rb new file mode 100644 index 00000000..f3aac28f --- /dev/null +++ b/lib/VoucherifySdk/models/discount_unit_multiple.rb @@ -0,0 +1,298 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountUnitMultiple + # Discount type. + attr_accessor :type + + # Defines how the discount is applied to the customer's order. + attr_accessor :effect + + attr_accessor :units + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'effect' => :'effect', + :'units' => :'units' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'effect' => :'String', + :'units' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::DiscountUnitMultiple` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::DiscountUnitMultiple`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'UNIT' + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + else + self.effect = 'ADD_MANY_ITEMS' + end + + if attributes.key?(:'units') + if (value = attributes[:'units']).is_a?(Array) + self.units = value + end + else + self.units = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @units.nil? + invalid_properties.push('invalid value for "units", units cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["UNIT"]) + return false unless type_validator.valid?(@type) + effect_validator = EnumAttributeValidator.new('String', ["ADD_MANY_ITEMS"]) + return false unless effect_validator.valid?(@effect) + return false if @units.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["UNIT"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] effect Object to be assigned + def effect=(effect) + validator = EnumAttributeValidator.new('String', ["ADD_MANY_ITEMS"]) + unless validator.valid?(effect) + fail ArgumentError, "invalid value for \"effect\", must be one of #{validator.allowable_values}." + end + @effect = effect + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + effect == o.effect && + units == o.units + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, effect, units].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount_unit_multiple_one_unit.rb b/lib/VoucherifySdk/models/discount_unit_multiple_one_unit.rb new file mode 100644 index 00000000..2e4fe919 --- /dev/null +++ b/lib/VoucherifySdk/models/discount_unit_multiple_one_unit.rb @@ -0,0 +1,310 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountUnitMultipleOneUnit + # Number of units to be granted a full value discount. + attr_accessor :unit_off + + attr_accessor :unit_off_formula + + # Defines how the unit is added to the customer's order. + attr_accessor :effect + + # The product deemed as free, chosen from product inventory (e.g. time, items). + attr_accessor :unit_type + + attr_accessor :product + + attr_accessor :sku + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'unit_off' => :'unit_off', + :'unit_off_formula' => :'unit_off_formula', + :'effect' => :'effect', + :'unit_type' => :'unit_type', + :'product' => :'product', + :'sku' => :'sku' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'unit_off' => :'Float', + :'unit_off_formula' => :'String', + :'effect' => :'String', + :'unit_type' => :'String', + :'product' => :'SimpleProductDiscountUnit', + :'sku' => :'SimpleSkuDiscountUnit' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::DiscountUnitMultipleOneUnit` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::DiscountUnitMultipleOneUnit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'unit_off') + self.unit_off = attributes[:'unit_off'] + end + + if attributes.key?(:'unit_off_formula') + self.unit_off_formula = attributes[:'unit_off_formula'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + else + self.effect = nil + end + + if attributes.key?(:'unit_type') + self.unit_type = attributes[:'unit_type'] + else + self.unit_type = nil + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @effect.nil? + invalid_properties.push('invalid value for "effect", effect cannot be nil.') + end + + if @unit_type.nil? + invalid_properties.push('invalid value for "unit_type", unit_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @effect.nil? + effect_validator = EnumAttributeValidator.new('String', ["ADD_NEW_ITEMS", "ADD_MISSING_ITEMS"]) + return false unless effect_validator.valid?(@effect) + return false if @unit_type.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] effect Object to be assigned + def effect=(effect) + validator = EnumAttributeValidator.new('String', ["ADD_NEW_ITEMS", "ADD_MISSING_ITEMS"]) + unless validator.valid?(effect) + fail ArgumentError, "invalid value for \"effect\", must be one of #{validator.allowable_values}." + end + @effect = effect + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + unit_off == o.unit_off && + unit_off_formula == o.unit_off_formula && + effect == o.effect && + unit_type == o.unit_type && + product == o.product && + sku == o.sku + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [unit_off, unit_off_formula, effect, unit_type, product, sku].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/discount_unit_vouchers_effect_types.rb b/lib/VoucherifySdk/models/discount_unit_vouchers_effect_types.rb new file mode 100644 index 00000000..e8bb20b9 --- /dev/null +++ b/lib/VoucherifySdk/models/discount_unit_vouchers_effect_types.rb @@ -0,0 +1,41 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class DiscountUnitVouchersEffectTypes + MISSING_ITEMS = "ADD_MISSING_ITEMS".freeze + NEW_ITEMS = "ADD_NEW_ITEMS".freeze + MANY_ITEMS = "ADD_MANY_ITEMS".freeze + + def self.all_vars + @all_vars ||= [MISSING_ITEMS, NEW_ITEMS, MANY_ITEMS].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if DiscountUnitVouchersEffectTypes.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #DiscountUnitVouchersEffectTypes" + end + end +end diff --git a/lib/VoucherifySdk/models/earning_rule.rb b/lib/VoucherifySdk/models/earning_rule.rb new file mode 100644 index 00000000..4e54781b --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule.rb @@ -0,0 +1,474 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRule + # Assigned by the Voucherify API, identifies the earning rule object. + attr_accessor :id + + # Timestamp representing the date and time when the earning rule was created in ISO 8601 format. + attr_accessor :created_at + + attr_accessor :loyalty + + attr_accessor :event + + attr_accessor :custom_event + + attr_accessor :segment + + attr_accessor :source + + # The type of object represented by JSON. Default is earning_rule. + attr_accessor :object + + # For internal use by Voucherify. + attr_accessor :automation_id + + # Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. + attr_accessor :start_date + + # Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. + attr_accessor :metadata + + # A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. + attr_accessor :validation_rule_id + + # Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. + attr_accessor :updated_at + + # A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. - `true` indicates an active earning rule - `false` indicates an inactive earning rule + attr_accessor :active + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'loyalty' => :'loyalty', + :'event' => :'event', + :'custom_event' => :'custom_event', + :'segment' => :'segment', + :'source' => :'source', + :'object' => :'object', + :'automation_id' => :'automation_id', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'metadata' => :'metadata', + :'validation_rule_id' => :'validation_rule_id', + :'updated_at' => :'updated_at', + :'active' => :'active' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'loyalty' => :'EarningRuleBaseLoyalty', + :'event' => :'EarningRuleEvent', + :'custom_event' => :'EarningRuleBaseCustomEvent', + :'segment' => :'EarningRuleBaseSegment', + :'source' => :'EarningRuleBaseSource', + :'object' => :'String', + :'automation_id' => :'String', + :'start_date' => :'String', + :'expiration_date' => :'String', + :'validity_timeframe' => :'EarningRuleBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'metadata' => :'Object', + :'validation_rule_id' => :'String', + :'updated_at' => :'Time', + :'active' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'validation_rule_id', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EarningRuleBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRule` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRule`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'event') + self.event = attributes[:'event'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'earning_rule' + end + + if attributes.key?(:'automation_id') + self.automation_id = attributes[:'automation_id'] + else + self.automation_id = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'validation_rule_id') + self.validation_rule_id = attributes[:'validation_rule_id'] + else + self.validation_rule_id = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + else + self.active = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + if @source.nil? + invalid_properties.push('invalid value for "source", source cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @automation_id.nil? + invalid_properties.push('invalid value for "automation_id", automation_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @active.nil? + invalid_properties.push('invalid value for "active", active cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @created_at.nil? + return false if @loyalty.nil? + return false if @source.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["earning_rule"]) + return false unless object_validator.valid?(@object) + return false if @automation_id.nil? + return false if @metadata.nil? + return false if @active.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["earning_rule"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + loyalty == o.loyalty && + event == o.event && + custom_event == o.custom_event && + segment == o.segment && + source == o.source && + object == o.object && + automation_id == o.automation_id && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + metadata == o.metadata && + validation_rule_id == o.validation_rule_id && + updated_at == o.updated_at && + active == o.active + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, loyalty, event, custom_event, segment, source, object, automation_id, start_date, expiration_date, validity_timeframe, validity_day_of_week, metadata, validation_rule_id, updated_at, active].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_base.rb b/lib/VoucherifySdk/models/earning_rule_base.rb new file mode 100644 index 00000000..923b854b --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_base.rb @@ -0,0 +1,424 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleBase + # Assigned by the Voucherify API, identifies the earning rule object. + attr_accessor :id + + # Timestamp representing the date and time when the earning rule was created in ISO 8601 format. + attr_accessor :created_at + + attr_accessor :loyalty + + attr_accessor :event + + attr_accessor :custom_event + + attr_accessor :segment + + attr_accessor :source + + # The type of object represented by JSON. Default is earning_rule. + attr_accessor :object + + # For internal use by Voucherify. + attr_accessor :automation_id + + # Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. + attr_accessor :start_date + + # Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'loyalty' => :'loyalty', + :'event' => :'event', + :'custom_event' => :'custom_event', + :'segment' => :'segment', + :'source' => :'source', + :'object' => :'object', + :'automation_id' => :'automation_id', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'loyalty' => :'EarningRuleBaseLoyalty', + :'event' => :'EarningRuleEvent', + :'custom_event' => :'EarningRuleBaseCustomEvent', + :'segment' => :'EarningRuleBaseSegment', + :'source' => :'EarningRuleBaseSource', + :'object' => :'String', + :'automation_id' => :'String', + :'start_date' => :'String', + :'expiration_date' => :'String', + :'validity_timeframe' => :'EarningRuleBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'event') + self.event = attributes[:'event'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'earning_rule' + end + + if attributes.key?(:'automation_id') + self.automation_id = attributes[:'automation_id'] + else + self.automation_id = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + if @source.nil? + invalid_properties.push('invalid value for "source", source cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @automation_id.nil? + invalid_properties.push('invalid value for "automation_id", automation_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @created_at.nil? + return false if @loyalty.nil? + return false if @source.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["earning_rule"]) + return false unless object_validator.valid?(@object) + return false if @automation_id.nil? + return false if @metadata.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["earning_rule"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + loyalty == o.loyalty && + event == o.event && + custom_event == o.custom_event && + segment == o.segment && + source == o.source && + object == o.object && + automation_id == o.automation_id && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, loyalty, event, custom_event, segment, source, object, automation_id, start_date, expiration_date, validity_timeframe, validity_day_of_week, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_base_custom_event.rb b/lib/VoucherifySdk/models/earning_rule_base_custom_event.rb new file mode 100644 index 00000000..2df9cc62 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_base_custom_event.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleBaseCustomEvent + attr_accessor :schema_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'schema_id' => :'schema_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'schema_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleBaseCustomEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleBaseCustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'schema_id') + self.schema_id = attributes[:'schema_id'] + else + self.schema_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @schema_id.nil? + invalid_properties.push('invalid value for "schema_id", schema_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @schema_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + schema_id == o.schema_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [schema_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_base_loyalty.rb b/lib/VoucherifySdk/models/earning_rule_base_loyalty.rb new file mode 100644 index 00000000..37990736 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_base_loyalty.rb @@ -0,0 +1,105 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module EarningRuleBaseLoyalty + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'EarningRuleFixed', + :'EarningRuleProportional' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_base_segment.rb b/lib/VoucherifySdk/models/earning_rule_base_segment.rb new file mode 100644 index 00000000..62d3dadb --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_base_segment.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the id of a customer segment. Required for the customer.segment.entered option in event. + class EarningRuleBaseSegment + # Contains a unique identifier of a customer segment. Assigned by the Voucherify API. + attr_accessor :id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleBaseSegment` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleBaseSegment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_base_source.rb b/lib/VoucherifySdk/models/earning_rule_base_source.rb new file mode 100644 index 00000000..756f6947 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_base_source.rb @@ -0,0 +1,284 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the custom earning rule name and parent campaign. + class EarningRuleBaseSource + # Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. + attr_accessor :banner + + # A unique campaign identifier assigned by the Voucherify API. + attr_accessor :object_id + + # Defines the object associated with the earning rule. Defaults to `campaign`. + attr_accessor :object_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'banner' => :'banner', + :'object_id' => :'object_id', + :'object_type' => :'object_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'banner' => :'String', + :'object_id' => :'String', + :'object_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleBaseSource` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleBaseSource`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'object_id') + self.object_id = attributes[:'object_id'] + else + self.object_id = nil + end + + if attributes.key?(:'object_type') + self.object_type = attributes[:'object_type'] + else + self.object_type = 'campaign' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object_id.nil? + invalid_properties.push('invalid value for "object_id", object_id cannot be nil.') + end + + if @object_type.nil? + invalid_properties.push('invalid value for "object_type", object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object_id.nil? + return false if @object_type.nil? + object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless object_type_validator.valid?(@object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object_type Object to be assigned + def object_type=(object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(object_type) + fail ArgumentError, "invalid value for \"object_type\", must be one of #{validator.allowable_values}." + end + @object_type = object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + banner == o.banner && + object_id == o.object_id && + object_type == o.object_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [banner, object_id, object_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_base_validity_timeframe.rb b/lib/VoucherifySdk/models/earning_rule_base_validity_timeframe.rb new file mode 100644 index 00000000..b77bbe79 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_base_validity_timeframe.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.start_date required when including the `validity_timeframe`. + class EarningRuleBaseValidityTimeframe + # Defines the amount of time an earning rule will be active in ISO 8601 format. For example, an earning rule with a duration of PT1H will be valid for a duration of one hour. + attr_accessor :duration + + # Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, an earning rule with an interval of P2D will be valid every other day. + attr_accessor :interval + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'duration' => :'duration', + :'interval' => :'interval' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'duration' => :'String', + :'interval' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleBaseValidityTimeframe` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleBaseValidityTimeframe`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + else + self.duration = nil + end + + if attributes.key?(:'interval') + self.interval = attributes[:'interval'] + else + self.interval = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @duration.nil? + invalid_properties.push('invalid value for "duration", duration cannot be nil.') + end + + if @interval.nil? + invalid_properties.push('invalid value for "interval", interval cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @duration.nil? + return false if @interval.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + duration == o.duration && + interval == o.interval + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [duration, interval].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_event.rb b/lib/VoucherifySdk/models/earning_rule_event.rb new file mode 100644 index 00000000..e0b2aba4 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_event.rb @@ -0,0 +1,46 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleEvent + ORDER_PAID = "order.paid".freeze + CUSTOMER_SEGMENT_ENTERED = "customer.segment.entered".freeze + CUSTOM_EVENT = "custom_event".freeze + CUSTOMER_LOYALTY_TIER_UPGRADED = "customer.loyalty.tier.upgraded".freeze + CUSTOMER_LOYALTY_TIER_DOWNGRADED = "customer.loyalty.tier.downgraded".freeze + CUSTOMER_LOYALTY_TIER_PROLONGED = "customer.loyalty.tier.prolonged".freeze + CUSTOMER_LOYALTY_TIER_JOINED = "customer.loyalty.tier.joined".freeze + CUSTOMER_LOYALTY_TIER_LEFT = "customer.loyalty.tier.left".freeze + + def self.all_vars + @all_vars ||= [ORDER_PAID, CUSTOMER_SEGMENT_ENTERED, CUSTOM_EVENT, CUSTOMER_LOYALTY_TIER_UPGRADED, CUSTOMER_LOYALTY_TIER_DOWNGRADED, CUSTOMER_LOYALTY_TIER_PROLONGED, CUSTOMER_LOYALTY_TIER_JOINED, CUSTOMER_LOYALTY_TIER_LEFT].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if EarningRuleEvent.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #EarningRuleEvent" + end + end +end diff --git a/lib/VoucherifySdk/models/earning_rule_fixed.rb b/lib/VoucherifySdk/models/earning_rule_fixed.rb new file mode 100644 index 00000000..9237a373 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_fixed.rb @@ -0,0 +1,261 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleFixed + # The number of points to be added to the loyalty card. + attr_accessor :type + + # Defines how the points will be added to the loyalty card. FIXED adds a fixed number of points. + attr_accessor :points + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleFixed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleFixed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'FIXED' + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["FIXED"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["FIXED"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional.rb b/lib/VoucherifySdk/models/earning_rule_proportional.rb new file mode 100644 index 00000000..34715282 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional.rb @@ -0,0 +1,107 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module EarningRuleProportional + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'EarningRuleProportionalCustomEvent', + :'EarningRuleProportionalCustomerMetadata', + :'EarningRuleProportionalOrder', + :'EarningRuleProportionalOrderItems' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_custom_event.rb b/lib/VoucherifySdk/models/earning_rule_proportional_custom_event.rb new file mode 100644 index 00000000..afef0a27 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_custom_event.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalCustomEvent + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # CUSTOM_EVENT_METADATA: Custom event metadata (X points for every Y in metadata attribute). + attr_accessor :calculation_type + + attr_accessor :custom_event + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'custom_event' => :'custom_event' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'custom_event' => :'EarningRuleProportionalCustomEventCustomEvent' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalCustomEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalCustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'CUSTOM_EVENT_METADATA' + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + else + self.custom_event = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @custom_event.nil? + invalid_properties.push('invalid value for "custom_event", custom_event cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["CUSTOM_EVENT_METADATA"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @custom_event.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["CUSTOM_EVENT_METADATA"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + custom_event == o.custom_event + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, custom_event].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event.rb b/lib/VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event.rb new file mode 100644 index 00000000..aa902cc6 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalCustomEventCustomEvent + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'metadata' => :'EarningRuleProportionalCustomEventCustomEventMetadata' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalCustomEventCustomEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalCustomEventCustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event_metadata.rb b/lib/VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event_metadata.rb new file mode 100644 index 00000000..d8ca4954 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_custom_event_custom_event_metadata.rb @@ -0,0 +1,257 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the ratio based on the property defined in the calculation_type parameter. For every given increment of value (1, 10, etc) defined in the every parameter for the property defined in calculation_type, give the customer the number of points defined in the points parameter. In other words, for every order metadata property value, give points. + class EarningRuleProportionalCustomEventCustomEventMetadata + # For how many increments of the customer metadata property to grant points for. + attr_accessor :every + + # Number of points to be awarded, i.e. how many points to be added to the loyalty card. + attr_accessor :points + + # Custom event metadata property. + attr_accessor :property + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'every' => :'every', + :'points' => :'points', + :'property' => :'property' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'every' => :'Integer', + :'points' => :'Integer', + :'property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalCustomEventCustomEventMetadata` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalCustomEventCustomEventMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'every') + self.every = attributes[:'every'] + else + self.every = nil + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'property') + self.property = attributes[:'property'] + else + self.property = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @every.nil? + invalid_properties.push('invalid value for "every", every cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @property.nil? + invalid_properties.push('invalid value for "property", property cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @every.nil? + return false if @points.nil? + return false if @property.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + every == o.every && + points == o.points && + property == o.property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [every, points, property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata.rb b/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata.rb new file mode 100644 index 00000000..97fc3d9d --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalCustomerMetadata + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # CUSTOMER_METADATA: Customer Metadata (X points for every Y in metadata attribute, defined in the property key under the customer.metadata object) + attr_accessor :calculation_type + + attr_accessor :customer + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'customer' => :'customer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'customer' => :'EarningRuleProportionalCustomerMetadataCustomer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalCustomerMetadata` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalCustomerMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'CUSTOMER_METADATA' + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["CUSTOMER_METADATA"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @customer.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["CUSTOMER_METADATA"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + customer == o.customer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, customer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer.rb b/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer.rb new file mode 100644 index 00000000..7b212c36 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalCustomerMetadataCustomer + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'metadata' => :'EarningRuleProportionalCustomerMetadataCustomerMetadata' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomer` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer_metadata.rb b/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer_metadata.rb new file mode 100644 index 00000000..53506524 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_customer_metadata_customer_metadata.rb @@ -0,0 +1,257 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the ratio based on the property defined in the calculation_type parameter. For every given increment of value (1, 10, etc) defined in the every parameter for the property defined in calculation_type, give the customer the number of points defined in the points parameter. In other words, for every order metadata property value, give points. + class EarningRuleProportionalCustomerMetadataCustomerMetadata + # For how many increments of the customer metadata property to grant points for. + attr_accessor :every + + # Number of points to be awarded, i.e. how many points to be added to the loyalty card. + attr_accessor :points + + # Customer metadata property. + attr_accessor :property + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'every' => :'every', + :'points' => :'points', + :'property' => :'property' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'every' => :'Integer', + :'points' => :'Integer', + :'property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomerMetadata` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalCustomerMetadataCustomerMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'every') + self.every = attributes[:'every'] + else + self.every = nil + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'property') + self.property = attributes[:'property'] + else + self.property = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @every.nil? + invalid_properties.push('invalid value for "every", every cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @property.nil? + invalid_properties.push('invalid value for "property", property cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @every.nil? + return false if @points.nil? + return false if @property.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + every == o.every && + points == o.points && + property == o.property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [every, points, property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order.rb new file mode 100644 index 00000000..4e355386 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module EarningRuleProportionalOrder + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'EarningRuleProportionalOrderAmount', + :'EarningRuleProportionalOrderMetadata', + :'EarningRuleProportionalOrderTotalAmount' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_amount.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_amount.rb new file mode 100644 index 00000000..f666d9fd --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_amount.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderAmount + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # `ORDER_AMOUNT`: Pre-discount order amount (X points for every Y spent excluding discounts) + attr_accessor :calculation_type + + attr_accessor :order + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'order' => :'order' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'order' => :'EarningRuleProportionalOrderAmountOrder' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderAmount` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'ORDER_AMOUNT' + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + else + self.order = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @order.nil? + invalid_properties.push('invalid value for "order", order cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["ORDER_AMOUNT"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @order.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["ORDER_AMOUNT"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + order == o.order + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, order].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_amount_order.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_amount_order.rb new file mode 100644 index 00000000..70e1d75e --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_amount_order.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderAmountOrder + attr_accessor :amount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'EarningRuleProportionalOrderAmountOrderAmount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderAmountOrder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderAmountOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @amount.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_amount_order_amount.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_amount_order_amount.rb new file mode 100644 index 00000000..532ebab4 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_amount_order_amount.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the ratio based on the property defined in the calculation_type parameter. For every set of value (1, 10, etc) defined in the every parameter for the property defined in calculation_type, give the customer the number of points defined in the points parameter. In other words, for every calculation_type, give points. + class EarningRuleProportionalOrderAmountOrderAmount + # Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 order amount is written as 1000. + attr_accessor :every + + # Number of points to be awarded, i.e. how many points to be added to the loyalty card. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'every' => :'every', + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'every' => :'Integer', + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderAmountOrderAmount` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderAmountOrderAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'every') + self.every = attributes[:'every'] + else + self.every = nil + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @every.nil? + invalid_properties.push('invalid value for "every", every cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @every.nil? + return false if @points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + every == o.every && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [every, points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items.rb new file mode 100644 index 00000000..a270eafc --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module EarningRuleProportionalOrderItems + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'EarningRuleProportionalOrderItemsAmount', + :'EarningRuleProportionalOrderItemsQuantity', + :'EarningRuleProportionalOrderItemsSubtotalAmount' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount.rb new file mode 100644 index 00000000..b2b296c4 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderItemsAmount + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # ORDER_ITEMS_AMOUNT; Pre-discount amount spent on items defined in the order_items.amount.object & .id (X points for every Y spent on items excluding discounts) + attr_accessor :calculation_type + + attr_accessor :order_items + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'order_items' => :'order_items' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'order_items' => :'EarningRuleProportionalOrderItemsAmountOrderItems' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderItemsAmount` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderItemsAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'ORDER_ITEMS_AMOUNT' + end + + if attributes.key?(:'order_items') + self.order_items = attributes[:'order_items'] + else + self.order_items = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @order_items.nil? + invalid_properties.push('invalid value for "order_items", order_items cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["ORDER_ITEMS_AMOUNT"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @order_items.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["ORDER_ITEMS_AMOUNT"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + order_items == o.order_items + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, order_items].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items.rb new file mode 100644 index 00000000..1cb16a20 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderItemsAmountOrderItems + attr_accessor :amount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'EarningRuleProportionalOrderItemsAmountOrderItemsAmount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItems` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItems`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @amount.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items_amount.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items_amount.rb new file mode 100644 index 00000000..e5dcc30e --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_amount_order_items_amount.rb @@ -0,0 +1,308 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the ratio based on the property defined in the calculation_type parameter. For every set of value (1, 10, etc) defined in the every parameter for the property defined in calculation_type, give the customer the number of points defined in the points parameter. In other words, for every calculation_type, give points. + class EarningRuleProportionalOrderItemsAmountOrderItemsAmount + # Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 order amount is written as 1000. + attr_accessor :every + + # Number of points to be awarded, i.e. how many points to be added to the loyalty card. + attr_accessor :points + + # Type of object taken under consideration. + attr_accessor :object + + # Unique ID of the resource, i.e. pc_75U0dHlr7u75BJodrW1AE3t6, prod_0bae32322150fd0546, or sku_0b7d7dfb090be5c619. + attr_accessor :id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'every' => :'every', + :'points' => :'points', + :'object' => :'object', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'every' => :'Integer', + :'points' => :'Integer', + :'object' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItemsAmount` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderItemsAmountOrderItemsAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'every') + self.every = attributes[:'every'] + else + self.every = nil + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @every.nil? + invalid_properties.push('invalid value for "every", every cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @every.nil? + return false if @points.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["products_collection", "product", "sku"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["products_collection", "product", "sku"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + every == o.every && + points == o.points && + object == o.object && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [every, points, object, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items_quantity.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_quantity.rb new file mode 100644 index 00000000..899faae5 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_quantity.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderItemsQuantity + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # `ORDER_ITEMS_QUANTITY`: Quantity of items defined in order_items.quantity.object & .id (X points for every Y items excluding free items) + attr_accessor :calculation_type + + attr_accessor :order_items + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'order_items' => :'order_items' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'order_items' => :'EarningRuleProportionalOrderItemsQuantityOrderItems' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderItemsQuantity` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderItemsQuantity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'ORDER_ITEMS_QUANTITY' + end + + if attributes.key?(:'order_items') + self.order_items = attributes[:'order_items'] + else + self.order_items = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @order_items.nil? + invalid_properties.push('invalid value for "order_items", order_items cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["ORDER_ITEMS_QUANTITY"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @order_items.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["ORDER_ITEMS_QUANTITY"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + order_items == o.order_items + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, order_items].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items_quantity_order_items.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_quantity_order_items.rb new file mode 100644 index 00000000..b2fe66b1 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_quantity_order_items.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderItemsQuantityOrderItems + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'quantity' => :'quantity' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'quantity' => :'EarningRuleProportionalOrderItemsAmountOrderItemsAmount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderItemsQuantityOrderItems` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderItemsQuantityOrderItems`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @quantity.nil? + invalid_properties.push('invalid value for "quantity", quantity cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @quantity.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + quantity == o.quantity + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [quantity].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount.rb new file mode 100644 index 00000000..94113729 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderItemsSubtotalAmount + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # ORDER_ITEMS_SUBTOTAL_AMOUNT; Amount spent on items defined in the order_items.subtotal_amount.object & .id (X points for every Y spent on items including discounts) + attr_accessor :calculation_type + + attr_accessor :order_items + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'order_items' => :'order_items' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'order_items' => :'EarningRuleProportionalOrderItemsSubtotalAmountOrderItems' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmount` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'ORDER_ITEMS_SUBTOTAL_AMOUNT' + end + + if attributes.key?(:'order_items') + self.order_items = attributes[:'order_items'] + else + self.order_items = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @order_items.nil? + invalid_properties.push('invalid value for "order_items", order_items cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["ORDER_ITEMS_SUBTOTAL_AMOUNT"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @order_items.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["ORDER_ITEMS_SUBTOTAL_AMOUNT"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + order_items == o.order_items + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, order_items].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount_order_items.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount_order_items.rb new file mode 100644 index 00000000..c5998eb2 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_items_subtotal_amount_order_items.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderItemsSubtotalAmountOrderItems + attr_accessor :subtotal_amount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'subtotal_amount' => :'subtotal_amount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'subtotal_amount' => :'EarningRuleProportionalOrderItemsAmountOrderItemsAmount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmountOrderItems` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderItemsSubtotalAmountOrderItems`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'subtotal_amount') + self.subtotal_amount = attributes[:'subtotal_amount'] + else + self.subtotal_amount = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @subtotal_amount.nil? + invalid_properties.push('invalid value for "subtotal_amount", subtotal_amount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @subtotal_amount.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + subtotal_amount == o.subtotal_amount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [subtotal_amount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata.rb new file mode 100644 index 00000000..100ff253 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderMetadata + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # `ORDER_METADATA`: Order Metadata (X points for every Y in metadata attribute, defined in the property key under the order.metadata object) + attr_accessor :calculation_type + + attr_accessor :order + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'order' => :'order' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'order' => :'EarningRuleProportionalOrderMetadataOrder' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderMetadata` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'ORDER_METADATA' + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + else + self.order = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @order.nil? + invalid_properties.push('invalid value for "order", order cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["ORDER_METADATA"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @order.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["ORDER_METADATA"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + order == o.order + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, order].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata_order.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata_order.rb new file mode 100644 index 00000000..08f826fb --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata_order.rb @@ -0,0 +1,222 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the formula for calculating points proportionally. + class EarningRuleProportionalOrderMetadataOrder + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'metadata' => :'EarningRuleProportionalOrderMetadataOrderMetadata' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderMetadataOrder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderMetadataOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata_order_metadata.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata_order_metadata.rb new file mode 100644 index 00000000..cdc712c6 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_metadata_order_metadata.rb @@ -0,0 +1,257 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the ratio based on the property defined in the calculation_type parameter. For every given increment of value (1, 10, etc) defined in the every parameter for the property defined in calculation_type, give the customer the number of points defined in the points parameter. In other words, for every order metadata property value, give points. + class EarningRuleProportionalOrderMetadataOrderMetadata + # For how many increments of the order metadata property to grant points for. + attr_accessor :every + + # Number of points to be awarded, i.e. how many points to be added to the loyalty card. + attr_accessor :points + + # Order metadata property. + attr_accessor :property + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'every' => :'every', + :'points' => :'points', + :'property' => :'property' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'every' => :'Integer', + :'points' => :'Integer', + :'property' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderMetadataOrderMetadata` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderMetadataOrderMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'every') + self.every = attributes[:'every'] + else + self.every = nil + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'property') + self.property = attributes[:'property'] + else + self.property = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @every.nil? + invalid_properties.push('invalid value for "every", every cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @property.nil? + invalid_properties.push('invalid value for "property", property cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @every.nil? + return false if @points.nil? + return false if @property.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + every == o.every && + points == o.points && + property == o.property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [every, points, property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_total_amount.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_total_amount.rb new file mode 100644 index 00000000..07b93392 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_total_amount.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderTotalAmount + # Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio. + attr_accessor :type + + # `ORDER_TOTAL_AMOUNT`: Total order amount (X points for every Y spent including discount) + attr_accessor :calculation_type + + attr_accessor :order + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'calculation_type' => :'calculation_type', + :'order' => :'order' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'calculation_type' => :'String', + :'order' => :'EarningRuleProportionalOrderTotalAmountOrder' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderTotalAmount` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderTotalAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'PROPORTIONAL' + end + + if attributes.key?(:'calculation_type') + self.calculation_type = attributes[:'calculation_type'] + else + self.calculation_type = 'ORDER_TOTAL_AMOUNT' + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + else + self.order = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @calculation_type.nil? + invalid_properties.push('invalid value for "calculation_type", calculation_type cannot be nil.') + end + + if @order.nil? + invalid_properties.push('invalid value for "order", order cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + return false unless type_validator.valid?(@type) + return false if @calculation_type.nil? + calculation_type_validator = EnumAttributeValidator.new('String', ["ORDER_TOTAL_AMOUNT"]) + return false unless calculation_type_validator.valid?(@calculation_type) + return false if @order.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["PROPORTIONAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] calculation_type Object to be assigned + def calculation_type=(calculation_type) + validator = EnumAttributeValidator.new('String', ["ORDER_TOTAL_AMOUNT"]) + unless validator.valid?(calculation_type) + fail ArgumentError, "invalid value for \"calculation_type\", must be one of #{validator.allowable_values}." + end + @calculation_type = calculation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + calculation_type == o.calculation_type && + order == o.order + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, calculation_type, order].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/earning_rule_proportional_order_total_amount_order.rb b/lib/VoucherifySdk/models/earning_rule_proportional_order_total_amount_order.rb new file mode 100644 index 00000000..491a5ef2 --- /dev/null +++ b/lib/VoucherifySdk/models/earning_rule_proportional_order_total_amount_order.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EarningRuleProportionalOrderTotalAmountOrder + attr_accessor :total_amount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total_amount' => :'total_amount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total_amount' => :'EarningRuleProportionalOrderAmountOrderAmount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EarningRuleProportionalOrderTotalAmountOrder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EarningRuleProportionalOrderTotalAmountOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + else + self.total_amount = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @total_amount.nil? + invalid_properties.push('invalid value for "total_amount", total_amount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @total_amount.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_amount == o.total_amount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total_amount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/error.rb b/lib/VoucherifySdk/models/error.rb new file mode 100644 index 00000000..98a98ff3 --- /dev/null +++ b/lib/VoucherifySdk/models/error.rb @@ -0,0 +1,311 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Error details + class Error + # Error's HTTP status code. + attr_accessor :code + + # Short string describing the kind of error which occurred. + attr_accessor :key + + # A human-readable message providing a short description about the error. + attr_accessor :message + + # A human-readable message providing more details about the error. + attr_accessor :details + + # This ID is useful when troubleshooting and/or finding the root cause of an error response by our support team. + attr_accessor :request_id + + # Unique resource ID that can be used in another endpoint to get more details. + attr_accessor :resource_id + + # The resource type. + attr_accessor :resource_type + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'key' => :'key', + :'message' => :'message', + :'details' => :'details', + :'request_id' => :'request_id', + :'resource_id' => :'resource_id', + :'resource_type' => :'resource_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'Integer', + :'key' => :'String', + :'message' => :'String', + :'details' => :'String', + :'request_id' => :'String', + :'resource_id' => :'String', + :'resource_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Error` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Error`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'key') + self.key = attributes[:'key'] + else + self.key = nil + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + + if attributes.key?(:'details') + self.details = attributes[:'details'] + else + self.details = nil + end + + if attributes.key?(:'request_id') + self.request_id = attributes[:'request_id'] + else + self.request_id = nil + end + + if attributes.key?(:'resource_id') + self.resource_id = attributes[:'resource_id'] + end + + if attributes.key?(:'resource_type') + self.resource_type = attributes[:'resource_type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @key.nil? + invalid_properties.push('invalid value for "key", key cannot be nil.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + if @details.nil? + invalid_properties.push('invalid value for "details", details cannot be nil.') + end + + if @request_id.nil? + invalid_properties.push('invalid value for "request_id", request_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + return false if @key.nil? + return false if @message.nil? + return false if @details.nil? + return false if @request_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code && + key == o.key && + message == o.message && + details == o.details && + request_id == o.request_id && + resource_id == o.resource_id && + resource_type == o.resource_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [code, key, message, details, request_id, resource_id, resource_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_active_campaign_failed.rb b/lib/VoucherifySdk/models/event_customer_active_campaign_failed.rb new file mode 100644 index 00000000..225cfaf0 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_active_campaign_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.activecampaign.failed`. + class EventCustomerActiveCampaignFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerActiveCampaignFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerActiveCampaignFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_active_campaign_recovered.rb b/lib/VoucherifySdk/models/event_customer_active_campaign_recovered.rb new file mode 100644 index 00000000..4bef7abc --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_active_campaign_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.activecampaign.recovered`. + class EventCustomerActiveCampaignRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerActiveCampaignRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerActiveCampaignRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_active_campaign_sent.rb b/lib/VoucherifySdk/models/event_customer_active_campaign_sent.rb new file mode 100644 index 00000000..a4676765 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_active_campaign_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.activecampaign.sent`. + class EventCustomerActiveCampaignSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerActiveCampaignSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerActiveCampaignSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_batch_failed.rb b/lib/VoucherifySdk/models/event_customer_batch_failed.rb new file mode 100644 index 00000000..171ff9b1 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_batch_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.batch.failed`. + class EventCustomerBatchFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerBatchFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerBatchFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_batch_recovered.rb b/lib/VoucherifySdk/models/event_customer_batch_recovered.rb new file mode 100644 index 00000000..6741656f --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_batch_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.batch.recovered`. + class EventCustomerBatchRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerBatchRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerBatchRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_batch_sent.rb b/lib/VoucherifySdk/models/event_customer_batch_sent.rb new file mode 100644 index 00000000..e8fbabaf --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_batch_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.batch.sent`. + class EventCustomerBatchSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerBatchSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerBatchSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_braze_failed.rb b/lib/VoucherifySdk/models/event_customer_braze_failed.rb new file mode 100644 index 00000000..1b5b4727 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_braze_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.braze.failed`. + class EventCustomerBrazeFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerBrazeFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerBrazeFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_braze_recovered.rb b/lib/VoucherifySdk/models/event_customer_braze_recovered.rb new file mode 100644 index 00000000..508368e4 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_braze_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.braze.recovered`. + class EventCustomerBrazeRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerBrazeRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerBrazeRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_braze_sent.rb b/lib/VoucherifySdk/models/event_customer_braze_sent.rb new file mode 100644 index 00000000..a118d7e9 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_braze_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.braze.sent`. + class EventCustomerBrazeSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerBrazeSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerBrazeSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_confirmed.rb b/lib/VoucherifySdk/models/event_customer_confirmed.rb new file mode 100644 index 00000000..b45ca298 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_confirmed.rb @@ -0,0 +1,224 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.confirmed`. + class EventCustomerConfirmed + attr_accessor :customer + + attr_accessor :unconfirmed_customer + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'unconfirmed_customer' => :'unconfirmed_customer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'unconfirmed_customer' => :'EventCustomerConfirmedUnconfirmedCustomer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerConfirmed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerConfirmed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'unconfirmed_customer') + self.unconfirmed_customer = attributes[:'unconfirmed_customer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + unconfirmed_customer == o.unconfirmed_customer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, unconfirmed_customer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_confirmed_unconfirmed_customer.rb b/lib/VoucherifySdk/models/event_customer_confirmed_unconfirmed_customer.rb new file mode 100644 index 00000000..0edb88f0 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_confirmed_unconfirmed_customer.rb @@ -0,0 +1,214 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerConfirmedUnconfirmedCustomer + attr_accessor :id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerConfirmedUnconfirmedCustomer` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerConfirmedUnconfirmedCustomer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_consents.rb b/lib/VoucherifySdk/models/event_customer_consents.rb new file mode 100644 index 00000000..1df4b348 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_consents.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerConsents + attr_accessor :customer + + attr_accessor :consents + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'consents' => :'consents' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'consents' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerConsents` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerConsents`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'consents') + if (value = attributes[:'consents']).is_a?(Array) + self.consents = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + consents == o.consents + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, consents].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_consents_given.rb b/lib/VoucherifySdk/models/event_customer_consents_given.rb new file mode 100644 index 00000000..9c0e581e --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_consents_given.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.consents.given`. + class EventCustomerConsentsGiven + attr_accessor :customer + + attr_accessor :consents + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'consents' => :'consents' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'consents' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerConsents' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerConsentsGiven` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerConsentsGiven`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'consents') + if (value = attributes[:'consents']).is_a?(Array) + self.consents = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + consents == o.consents + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, consents].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_consents_revoked.rb b/lib/VoucherifySdk/models/event_customer_consents_revoked.rb new file mode 100644 index 00000000..878c1636 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_consents_revoked.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.consents.revoked`. + class EventCustomerConsentsRevoked + attr_accessor :customer + + attr_accessor :consents + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'consents' => :'consents' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'consents' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerConsents' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerConsentsRevoked` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerConsentsRevoked`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'consents') + if (value = attributes[:'consents']).is_a?(Array) + self.consents = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + consents == o.consents + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, consents].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_created.rb b/lib/VoucherifySdk/models/event_customer_created.rb new file mode 100644 index 00000000..acf47e99 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_created.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.created`. + class EventCustomerCreated + attr_accessor :customer + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'CustomerWithSummaryLoyaltyReferrals' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerCreated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerCreated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_custom_event.rb b/lib/VoucherifySdk/models/event_customer_custom_event.rb new file mode 100644 index 00000000..101555c6 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_custom_event.rb @@ -0,0 +1,222 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.custom_event`. + class EventCustomerCustomEvent + attr_accessor :customer + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'CustomerWithSummaryLoyaltyReferrals' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerCustomEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerCustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @customer.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_deleted.rb b/lib/VoucherifySdk/models/event_customer_deleted.rb new file mode 100644 index 00000000..0bfabd19 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_deleted.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.deleted`. + class EventCustomerDeleted + attr_accessor :customer + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'CustomerWithSummaryLoyaltyReferrals' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerDeleted` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerDeleted`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_email_failed.rb b/lib/VoucherifySdk/models/event_customer_email_failed.rb new file mode 100644 index 00000000..110161d9 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_email_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.email.failed`. + class EventCustomerEmailFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerEmailFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerEmailFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_email_recovered.rb b/lib/VoucherifySdk/models/event_customer_email_recovered.rb new file mode 100644 index 00000000..e75dbac1 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_email_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.email.recovered`. + class EventCustomerEmailRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerEmailRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerEmailRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_email_sent.rb b/lib/VoucherifySdk/models/event_customer_email_sent.rb new file mode 100644 index 00000000..b8791ab5 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_email_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.email.sent`. + class EventCustomerEmailSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerEmailSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerEmailSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_failed.rb b/lib/VoucherifySdk/models/event_customer_failed.rb new file mode 100644 index 00000000..094645ac --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_failed.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_gift_voucher_balance_added.rb b/lib/VoucherifySdk/models/event_customer_gift_voucher_balance_added.rb new file mode 100644 index 00000000..28927021 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_gift_voucher_balance_added.rb @@ -0,0 +1,251 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.voucher.gift.balance_added`. + class EventCustomerGiftVoucherBalanceAdded + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :balance + + attr_accessor :transaction + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'balance' => :'balance', + :'transaction' => :'transaction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'balance' => :'Integer', + :'transaction' => :'VoucherTransaction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerGiftVoucherBalanceAdded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerGiftVoucherBalanceAdded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'transaction') + self.transaction = attributes[:'transaction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + voucher == o.voucher && + balance == o.balance && + transaction == o.transaction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, voucher, balance, transaction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_intercom_failed.rb b/lib/VoucherifySdk/models/event_customer_intercom_failed.rb new file mode 100644 index 00000000..778cb74b --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_intercom_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.intercom.failed`. + class EventCustomerIntercomFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerIntercomFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerIntercomFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_intercom_recovered.rb b/lib/VoucherifySdk/models/event_customer_intercom_recovered.rb new file mode 100644 index 00000000..e1b5897e --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_intercom_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.intercom.recovered`. + class EventCustomerIntercomRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerIntercomRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerIntercomRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_intercom_sent.rb b/lib/VoucherifySdk/models/event_customer_intercom_sent.rb new file mode 100644 index 00000000..da33154b --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_intercom_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.intercom.sent`. + class EventCustomerIntercomSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerIntercomSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerIntercomSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_klaviyo_failed.rb b/lib/VoucherifySdk/models/event_customer_klaviyo_failed.rb new file mode 100644 index 00000000..8739f0e3 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_klaviyo_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.klaviyo.failed`. + class EventCustomerKlaviyoFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerKlaviyoFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerKlaviyoFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_klaviyo_recovered.rb b/lib/VoucherifySdk/models/event_customer_klaviyo_recovered.rb new file mode 100644 index 00000000..f55cf1ed --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_klaviyo_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.klaviyo.recovered`. + class EventCustomerKlaviyoRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerKlaviyoRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerKlaviyoRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_klaviyo_sent.rb b/lib/VoucherifySdk/models/event_customer_klaviyo_sent.rb new file mode 100644 index 00000000..554a0451 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_klaviyo_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.klaviyo.sent`. + class EventCustomerKlaviyoSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerKlaviyoSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerKlaviyoSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_card_points_added.rb b/lib/VoucherifySdk/models/event_customer_loyalty_card_points_added.rb new file mode 100644 index 00000000..748ae6f7 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_card_points_added.rb @@ -0,0 +1,251 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.voucher.loyalty_card.points_added`. + class EventCustomerLoyaltyCardPointsAdded + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :balance + + attr_accessor :transaction + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'balance' => :'balance', + :'transaction' => :'transaction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'balance' => :'Integer', + :'transaction' => :'VoucherTransaction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyCardPointsAdded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyCardPointsAdded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'transaction') + self.transaction = attributes[:'transaction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + voucher == o.voucher && + balance == o.balance && + transaction == o.transaction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, voucher, balance, transaction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_card_points_transferred.rb b/lib/VoucherifySdk/models/event_customer_loyalty_card_points_transferred.rb new file mode 100644 index 00000000..72b05799 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_card_points_transferred.rb @@ -0,0 +1,269 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.voucher.loyalty_card.points_transferred`. + class EventCustomerLoyaltyCardPointsTransferred + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :source_voucher + + attr_accessor :destination_voucher + + attr_accessor :balance + + attr_accessor :transaction + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'source_voucher' => :'source_voucher', + :'destination_voucher' => :'destination_voucher', + :'balance' => :'balance', + :'transaction' => :'transaction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'source_voucher' => :'SimpleVoucher', + :'destination_voucher' => :'SimpleVoucher', + :'balance' => :'Integer', + :'transaction' => :'VoucherTransaction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyCardPointsTransferred` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyCardPointsTransferred`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'source_voucher') + self.source_voucher = attributes[:'source_voucher'] + end + + if attributes.key?(:'destination_voucher') + self.destination_voucher = attributes[:'destination_voucher'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'transaction') + self.transaction = attributes[:'transaction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + voucher == o.voucher && + source_voucher == o.source_voucher && + destination_voucher == o.destination_voucher && + balance == o.balance && + transaction == o.transaction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, voucher, source_voucher, destination_voucher, balance, transaction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_tier_base.rb b/lib/VoucherifySdk/models/event_customer_loyalty_tier_base.rb new file mode 100644 index 00000000..366c669a --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_tier_base.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerLoyaltyTierBase + attr_accessor :customer + + attr_accessor :campaign + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyTierBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyTierBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_tier_downgraded.rb b/lib/VoucherifySdk/models/event_customer_loyalty_tier_downgraded.rb new file mode 100644 index 00000000..854760a3 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_tier_downgraded.rb @@ -0,0 +1,279 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.loyalty.tier.downgraded`. + class EventCustomerLoyaltyTierDowngraded + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :loyalty_tier_from + + attr_accessor :loyalty_tier_to + + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'loyalty_tier_from' => :'loyalty_tier_from', + :'loyalty_tier_to' => :'loyalty_tier_to', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'loyalty_tier_from' => :'LoyaltyTier', + :'loyalty_tier_to' => :'LoyaltyTier', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerLoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyTierDowngraded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyTierDowngraded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty_tier_from') + self.loyalty_tier_from = attributes[:'loyalty_tier_from'] + else + self.loyalty_tier_from = nil + end + + if attributes.key?(:'loyalty_tier_to') + self.loyalty_tier_to = attributes[:'loyalty_tier_to'] + else + self.loyalty_tier_to = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty_tier_from.nil? + invalid_properties.push('invalid value for "loyalty_tier_from", loyalty_tier_from cannot be nil.') + end + + if @loyalty_tier_to.nil? + invalid_properties.push('invalid value for "loyalty_tier_to", loyalty_tier_to cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty_tier_from.nil? + return false if @loyalty_tier_to.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + loyalty_tier_from == o.loyalty_tier_from && + loyalty_tier_to == o.loyalty_tier_to && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, loyalty_tier_from, loyalty_tier_to, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_tier_expiration_changed.rb b/lib/VoucherifySdk/models/event_customer_loyalty_tier_expiration_changed.rb new file mode 100644 index 00000000..25dc50bb --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_tier_expiration_changed.rb @@ -0,0 +1,279 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.loyalty.tier.expiration.changed`. + class EventCustomerLoyaltyTierExpirationChanged + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :loyalty_tier + + attr_accessor :created_at + + attr_accessor :expiration_date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'loyalty_tier' => :'loyalty_tier', + :'created_at' => :'created_at', + :'expiration_date' => :'expiration_date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'loyalty_tier' => :'LoyaltyTier', + :'created_at' => :'Time', + :'expiration_date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerLoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyTierExpirationChanged` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyTierExpirationChanged`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty_tier') + self.loyalty_tier = attributes[:'loyalty_tier'] + else + self.loyalty_tier = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + else + self.expiration_date = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty_tier.nil? + invalid_properties.push('invalid value for "loyalty_tier", loyalty_tier cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @expiration_date.nil? + invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty_tier.nil? + return false if @created_at.nil? + return false if @expiration_date.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + loyalty_tier == o.loyalty_tier && + created_at == o.created_at && + expiration_date == o.expiration_date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, loyalty_tier, created_at, expiration_date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_tier_joined.rb b/lib/VoucherifySdk/models/event_customer_loyalty_tier_joined.rb new file mode 100644 index 00000000..27e75916 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_tier_joined.rb @@ -0,0 +1,263 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.loyalty.tier.joined`. + class EventCustomerLoyaltyTierJoined + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :loyalty_tier + + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'loyalty_tier' => :'loyalty_tier', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'loyalty_tier' => :'LoyaltyTier', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerLoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyTierJoined` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyTierJoined`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty_tier') + self.loyalty_tier = attributes[:'loyalty_tier'] + else + self.loyalty_tier = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty_tier.nil? + invalid_properties.push('invalid value for "loyalty_tier", loyalty_tier cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty_tier.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + loyalty_tier == o.loyalty_tier && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, loyalty_tier, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_tier_left.rb b/lib/VoucherifySdk/models/event_customer_loyalty_tier_left.rb new file mode 100644 index 00000000..342ccb6e --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_tier_left.rb @@ -0,0 +1,263 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.loyalty.tier.left`. + class EventCustomerLoyaltyTierLeft + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :loyalty_tier + + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'loyalty_tier' => :'loyalty_tier', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'loyalty_tier' => :'LoyaltyTier', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerLoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyTierLeft` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyTierLeft`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty_tier') + self.loyalty_tier = attributes[:'loyalty_tier'] + else + self.loyalty_tier = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty_tier.nil? + invalid_properties.push('invalid value for "loyalty_tier", loyalty_tier cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty_tier.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + loyalty_tier == o.loyalty_tier && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, loyalty_tier, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_tier_prolonged.rb b/lib/VoucherifySdk/models/event_customer_loyalty_tier_prolonged.rb new file mode 100644 index 00000000..dbe7ca8a --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_tier_prolonged.rb @@ -0,0 +1,263 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.loyalty.tier.prolonged`. + class EventCustomerLoyaltyTierProlonged + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :loyalty_tier + + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'loyalty_tier' => :'loyalty_tier', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'loyalty_tier' => :'LoyaltyTier', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerLoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyTierProlonged` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyTierProlonged`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty_tier') + self.loyalty_tier = attributes[:'loyalty_tier'] + else + self.loyalty_tier = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty_tier.nil? + invalid_properties.push('invalid value for "loyalty_tier", loyalty_tier cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty_tier.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + loyalty_tier == o.loyalty_tier && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, loyalty_tier, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_tier_upgraded.rb b/lib/VoucherifySdk/models/event_customer_loyalty_tier_upgraded.rb new file mode 100644 index 00000000..95b3b5f3 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_tier_upgraded.rb @@ -0,0 +1,272 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.loyalty.tier.upgraded`. + class EventCustomerLoyaltyTierUpgraded + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :loyalty_tier_from + + attr_accessor :loyalty_tier_to + + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'loyalty_tier_from' => :'loyalty_tier_from', + :'loyalty_tier_to' => :'loyalty_tier_to', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'loyalty_tier_from' => :'LoyaltyTier', + :'loyalty_tier_to' => :'LoyaltyTier', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerLoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyTierUpgraded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyTierUpgraded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty_tier_from') + self.loyalty_tier_from = attributes[:'loyalty_tier_from'] + end + + if attributes.key?(:'loyalty_tier_to') + self.loyalty_tier_to = attributes[:'loyalty_tier_to'] + else + self.loyalty_tier_to = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty_tier_to.nil? + invalid_properties.push('invalid value for "loyalty_tier_to", loyalty_tier_to cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty_tier_to.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + loyalty_tier_from == o.loyalty_tier_from && + loyalty_tier_to == o.loyalty_tier_to && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, loyalty_tier_from, loyalty_tier_to, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_loyalty_updated.rb b/lib/VoucherifySdk/models/event_customer_loyalty_updated.rb new file mode 100644 index 00000000..e036d93d --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_loyalty_updated.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.loyalty.updated`. + class EventCustomerLoyaltyUpdated + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :loyalty + + attr_accessor :created_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'loyalty' => :'loyalty', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'loyalty' => :'Object', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerLoyaltyUpdated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerLoyaltyUpdated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + loyalty == o.loyalty && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, loyalty, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_mailchimp_failed.rb b/lib/VoucherifySdk/models/event_customer_mailchimp_failed.rb new file mode 100644 index 00000000..4394556f --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_mailchimp_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.mailchimp.failed`. + class EventCustomerMailchimpFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerMailchimpFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerMailchimpFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_mailchimp_recovered.rb b/lib/VoucherifySdk/models/event_customer_mailchimp_recovered.rb new file mode 100644 index 00000000..9f61aea0 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_mailchimp_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.mailchimp.recovered`. + class EventCustomerMailchimpRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerMailchimpRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerMailchimpRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_mailchimp_sent.rb b/lib/VoucherifySdk/models/event_customer_mailchimp_sent.rb new file mode 100644 index 00000000..91f9865b --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_mailchimp_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.mailchimp.sent`. + class EventCustomerMailchimpSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerMailchimpSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerMailchimpSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_order.rb b/lib/VoucherifySdk/models/event_customer_order.rb new file mode 100644 index 00000000..5c0d999b --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_order.rb @@ -0,0 +1,241 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerOrder + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :order + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'order' => :'order', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'order' => :'OrderCalculated', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerOrder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + order == o.order && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, order, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_order_canceled.rb b/lib/VoucherifySdk/models/event_customer_order_canceled.rb new file mode 100644 index 00000000..fe1b142d --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_order_canceled.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.order.canceled`. + class EventCustomerOrderCanceled + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :order + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'order' => :'order', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'order' => :'OrderCalculated', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerOrder' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerOrderCanceled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerOrderCanceled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + order == o.order && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, order, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_order_created.rb b/lib/VoucherifySdk/models/event_customer_order_created.rb new file mode 100644 index 00000000..3b0f6849 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_order_created.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.order.created`. + class EventCustomerOrderCreated + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :order + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'order' => :'order', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'order' => :'OrderCalculated', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerOrder' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerOrderCreated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerOrderCreated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + order == o.order && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, order, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_order_fulfilled.rb b/lib/VoucherifySdk/models/event_customer_order_fulfilled.rb new file mode 100644 index 00000000..28bb3ea5 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_order_fulfilled.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.order.fulfilled`. + class EventCustomerOrderFulfilled + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :order + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'order' => :'order', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'order' => :'OrderCalculated', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerOrder' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerOrderFulfilled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerOrderFulfilled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + order == o.order && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, order, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_order_paid.rb b/lib/VoucherifySdk/models/event_customer_order_paid.rb new file mode 100644 index 00000000..a7d41449 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_order_paid.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.order.paid`. + class EventCustomerOrderPaid + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :order + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'order' => :'order', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'order' => :'OrderCalculated', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerOrder' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerOrderPaid` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerOrderPaid`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + order == o.order && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, order, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_order_processing.rb b/lib/VoucherifySdk/models/event_customer_order_processing.rb new file mode 100644 index 00000000..70cda7c8 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_order_processing.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.order.processing`. + class EventCustomerOrderProcessing + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :order + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'order' => :'order', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'order' => :'OrderCalculated', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerOrder' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerOrderProcessing` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerOrderProcessing`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + order == o.order && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, order, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_order_updated.rb b/lib/VoucherifySdk/models/event_customer_order_updated.rb new file mode 100644 index 00000000..255f26f4 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_order_updated.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.order.updated`. + class EventCustomerOrderUpdated + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :order + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'order' => :'order', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'order' => :'OrderCalculated', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerOrder' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerOrderUpdated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerOrderUpdated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + order == o.order && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, order, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_publication_failed.rb b/lib/VoucherifySdk/models/event_customer_publication_failed.rb new file mode 100644 index 00000000..004fdded --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_publication_failed.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.publication.failed`. + class EventCustomerPublicationFailed + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :publication + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'publication' => :'publication' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'publication' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerPublicationFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerPublicationFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'publication') + self.publication = attributes[:'publication'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + publication == o.publication + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, publication].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_publication_succeeded.rb b/lib/VoucherifySdk/models/event_customer_publication_succeeded.rb new file mode 100644 index 00000000..e66ed773 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_publication_succeeded.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.publication.succeeded`. + class EventCustomerPublicationSucceeded + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :publication + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'publication' => :'publication' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'publication' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerPublicationSucceeded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerPublicationSucceeded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'publication') + self.publication = attributes[:'publication'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + publication == o.publication + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, publication].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_recovered.rb b/lib/VoucherifySdk/models/event_customer_recovered.rb new file mode 100644 index 00000000..2501513b --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_recovered.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_redemption.rb b/lib/VoucherifySdk/models/event_customer_redemption.rb new file mode 100644 index 00000000..43ffba41 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_redemption.rb @@ -0,0 +1,268 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerRedemption + attr_accessor :customer + + attr_accessor :order + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :holder + + attr_accessor :promotion_tier + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'order' => :'order', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'holder' => :'holder', + :'promotion_tier' => :'promotion_tier', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'order' => :'SimpleOrder', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'holder' => :'SimpleCustomer', + :'promotion_tier' => :'SimplePromotionTier', + :'redemption' => :'SimpleRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + order == o.order && + campaign == o.campaign && + voucher == o.voucher && + holder == o.holder && + promotion_tier == o.promotion_tier && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, order, campaign, voucher, holder, promotion_tier, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_redemption_failed.rb b/lib/VoucherifySdk/models/event_customer_redemption_failed.rb new file mode 100644 index 00000000..ece2772d --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_redemption_failed.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.redemption.failed`. + class EventCustomerRedemptionFailed + attr_accessor :customer + + attr_accessor :order + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :holder + + attr_accessor :promotion_tier + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'order' => :'order', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'holder' => :'holder', + :'promotion_tier' => :'promotion_tier', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'order' => :'SimpleOrder', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'holder' => :'SimpleCustomer', + :'promotion_tier' => :'SimplePromotionTier', + :'redemption' => :'SimpleRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRedemption' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRedemptionFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRedemptionFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + order == o.order && + campaign == o.campaign && + voucher == o.voucher && + holder == o.holder && + promotion_tier == o.promotion_tier && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, order, campaign, voucher, holder, promotion_tier, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_redemption_rollback_failed.rb b/lib/VoucherifySdk/models/event_customer_redemption_rollback_failed.rb new file mode 100644 index 00000000..01f0c134 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_redemption_rollback_failed.rb @@ -0,0 +1,285 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.redemption.rollback.failed`. + class EventCustomerRedemptionRollbackFailed + attr_accessor :customer + + attr_accessor :order + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :holder + + attr_accessor :promotion_tier + + attr_accessor :redemption + + attr_accessor :redemption_rollback + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'order' => :'order', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'holder' => :'holder', + :'promotion_tier' => :'promotion_tier', + :'redemption' => :'redemption', + :'redemption_rollback' => :'redemption_rollback' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'order' => :'SimpleOrder', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'holder' => :'SimpleCustomer', + :'promotion_tier' => :'SimplePromotionTier', + :'redemption' => :'SimpleRedemption', + :'redemption_rollback' => :'SimpleRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRedemption' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRedemptionRollbackFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRedemptionRollbackFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'redemption_rollback') + self.redemption_rollback = attributes[:'redemption_rollback'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + order == o.order && + campaign == o.campaign && + voucher == o.voucher && + holder == o.holder && + promotion_tier == o.promotion_tier && + redemption == o.redemption && + redemption_rollback == o.redemption_rollback + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, order, campaign, voucher, holder, promotion_tier, redemption, redemption_rollback].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_redemption_rollback_succeeded.rb b/lib/VoucherifySdk/models/event_customer_redemption_rollback_succeeded.rb new file mode 100644 index 00000000..779f7b96 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_redemption_rollback_succeeded.rb @@ -0,0 +1,285 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.redemption.rollback.succeeded`. + class EventCustomerRedemptionRollbackSucceeded + attr_accessor :customer + + attr_accessor :order + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :holder + + attr_accessor :promotion_tier + + attr_accessor :redemption + + attr_accessor :redemption_rollback + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'order' => :'order', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'holder' => :'holder', + :'promotion_tier' => :'promotion_tier', + :'redemption' => :'redemption', + :'redemption_rollback' => :'redemption_rollback' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'order' => :'SimpleOrder', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'holder' => :'SimpleCustomer', + :'promotion_tier' => :'SimplePromotionTier', + :'redemption' => :'SimpleRedemption', + :'redemption_rollback' => :'SimpleRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRedemption' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRedemptionRollbackSucceeded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRedemptionRollbackSucceeded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'redemption_rollback') + self.redemption_rollback = attributes[:'redemption_rollback'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + order == o.order && + campaign == o.campaign && + voucher == o.voucher && + holder == o.holder && + promotion_tier == o.promotion_tier && + redemption == o.redemption && + redemption_rollback == o.redemption_rollback + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, order, campaign, voucher, holder, promotion_tier, redemption, redemption_rollback].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_redemption_succeeded.rb b/lib/VoucherifySdk/models/event_customer_redemption_succeeded.rb new file mode 100644 index 00000000..322f8039 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_redemption_succeeded.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.redemption.succeeded`. + class EventCustomerRedemptionSucceeded + attr_accessor :customer + + attr_accessor :order + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :holder + + attr_accessor :promotion_tier + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'order' => :'order', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'holder' => :'holder', + :'promotion_tier' => :'promotion_tier', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'order' => :'SimpleOrder', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'holder' => :'SimpleCustomer', + :'promotion_tier' => :'SimplePromotionTier', + :'redemption' => :'SimpleRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRedemption' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRedemptionSucceeded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRedemptionSucceeded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + order == o.order && + campaign == o.campaign && + voucher == o.voucher && + holder == o.holder && + promotion_tier == o.promotion_tier && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, order, campaign, voucher, holder, promotion_tier, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_referred.rb b/lib/VoucherifySdk/models/event_customer_referred.rb new file mode 100644 index 00000000..54e39c75 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_referred.rb @@ -0,0 +1,288 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.referred`. + class EventCustomerReferred + attr_accessor :customer + + attr_accessor :referrer + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :custom_event + + attr_accessor :redemption + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'referrer' => :'referrer', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'custom_event' => :'custom_event', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'referrer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'custom_event' => :'CustomEvent', + :'redemption' => :'RedemptionInternal' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerReferred` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerReferred`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + else + self.referrer = nil + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + else + self.campaign = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + else + self.voucher = nil + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + else + self.custom_event = nil + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @referrer.nil? + invalid_properties.push('invalid value for "referrer", referrer cannot be nil.') + end + + if @campaign.nil? + invalid_properties.push('invalid value for "campaign", campaign cannot be nil.') + end + + if @voucher.nil? + invalid_properties.push('invalid value for "voucher", voucher cannot be nil.') + end + + if @custom_event.nil? + invalid_properties.push('invalid value for "custom_event", custom_event cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @referrer.nil? + return false if @campaign.nil? + return false if @voucher.nil? + return false if @custom_event.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + referrer == o.referrer && + campaign == o.campaign && + voucher == o.voucher && + custom_event == o.custom_event && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, referrer, campaign, voucher, custom_event, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_reward_redemptions.rb b/lib/VoucherifySdk/models/event_customer_reward_redemptions.rb new file mode 100644 index 00000000..d095fbbe --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_reward_redemptions.rb @@ -0,0 +1,286 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerRewardRedemptions + attr_accessor :customer + + attr_accessor :holder + + attr_accessor :voucher + + attr_accessor :campaign + + attr_accessor :reward_redemption + + attr_accessor :reward + + attr_accessor :reward_assignment + + attr_accessor :source + + attr_accessor :balance + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'holder' => :'holder', + :'voucher' => :'voucher', + :'campaign' => :'campaign', + :'reward_redemption' => :'reward_redemption', + :'reward' => :'reward', + :'reward_assignment' => :'reward_assignment', + :'source' => :'source', + :'balance' => :'balance' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'holder' => :'SimpleCustomer', + :'voucher' => :'SimpleVoucher', + :'campaign' => :'SimpleCampaign', + :'reward_redemption' => :'Object', + :'reward' => :'SimpleRedemptionRewardResult', + :'reward_assignment' => :'RewardAssignment', + :'source' => :'String', + :'balance' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRewardRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRewardRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'reward_redemption') + self.reward_redemption = attributes[:'reward_redemption'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'reward_assignment') + self.reward_assignment = attributes[:'reward_assignment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + holder == o.holder && + voucher == o.voucher && + campaign == o.campaign && + reward_redemption == o.reward_redemption && + reward == o.reward && + reward_assignment == o.reward_assignment && + source == o.source && + balance == o.balance + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, holder, voucher, campaign, reward_redemption, reward, reward_assignment, source, balance].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_reward_redemptions_completed.rb b/lib/VoucherifySdk/models/event_customer_reward_redemptions_completed.rb new file mode 100644 index 00000000..3aab7014 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_reward_redemptions_completed.rb @@ -0,0 +1,294 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.reward_redemptions.completed`. + class EventCustomerRewardRedemptionsCompleted + attr_accessor :customer + + attr_accessor :holder + + attr_accessor :voucher + + attr_accessor :campaign + + attr_accessor :reward_redemption + + attr_accessor :reward + + attr_accessor :reward_assignment + + attr_accessor :source + + attr_accessor :balance + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'holder' => :'holder', + :'voucher' => :'voucher', + :'campaign' => :'campaign', + :'reward_redemption' => :'reward_redemption', + :'reward' => :'reward', + :'reward_assignment' => :'reward_assignment', + :'source' => :'source', + :'balance' => :'balance' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'holder' => :'SimpleCustomer', + :'voucher' => :'SimpleVoucher', + :'campaign' => :'SimpleCampaign', + :'reward_redemption' => :'Object', + :'reward' => :'SimpleRedemptionRewardResult', + :'reward_assignment' => :'RewardAssignment', + :'source' => :'String', + :'balance' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRewardRedemptions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRewardRedemptionsCompleted` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRewardRedemptionsCompleted`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'reward_redemption') + self.reward_redemption = attributes[:'reward_redemption'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'reward_assignment') + self.reward_assignment = attributes[:'reward_assignment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + holder == o.holder && + voucher == o.voucher && + campaign == o.campaign && + reward_redemption == o.reward_redemption && + reward == o.reward && + reward_assignment == o.reward_assignment && + source == o.source && + balance == o.balance + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, holder, voucher, campaign, reward_redemption, reward, reward_assignment, source, balance].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_reward_redemptions_created.rb b/lib/VoucherifySdk/models/event_customer_reward_redemptions_created.rb new file mode 100644 index 00000000..650ac623 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_reward_redemptions_created.rb @@ -0,0 +1,294 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.reward_redemptions.created`. + class EventCustomerRewardRedemptionsCreated + attr_accessor :customer + + attr_accessor :holder + + attr_accessor :voucher + + attr_accessor :campaign + + attr_accessor :reward_redemption + + attr_accessor :reward + + attr_accessor :reward_assignment + + attr_accessor :source + + attr_accessor :balance + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'holder' => :'holder', + :'voucher' => :'voucher', + :'campaign' => :'campaign', + :'reward_redemption' => :'reward_redemption', + :'reward' => :'reward', + :'reward_assignment' => :'reward_assignment', + :'source' => :'source', + :'balance' => :'balance' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'holder' => :'SimpleCustomer', + :'voucher' => :'SimpleVoucher', + :'campaign' => :'SimpleCampaign', + :'reward_redemption' => :'Object', + :'reward' => :'SimpleRedemptionRewardResult', + :'reward_assignment' => :'RewardAssignment', + :'source' => :'String', + :'balance' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRewardRedemptions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRewardRedemptionsCreated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRewardRedemptionsCreated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'reward_redemption') + self.reward_redemption = attributes[:'reward_redemption'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'reward_assignment') + self.reward_assignment = attributes[:'reward_assignment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + holder == o.holder && + voucher == o.voucher && + campaign == o.campaign && + reward_redemption == o.reward_redemption && + reward == o.reward && + reward_assignment == o.reward_assignment && + source == o.source && + balance == o.balance + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, holder, voucher, campaign, reward_redemption, reward, reward_assignment, source, balance].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_reward_redemptions_pending.rb b/lib/VoucherifySdk/models/event_customer_reward_redemptions_pending.rb new file mode 100644 index 00000000..31fb4a21 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_reward_redemptions_pending.rb @@ -0,0 +1,294 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.reward_redemptions.pending`. + class EventCustomerRewardRedemptionsPending + attr_accessor :customer + + attr_accessor :holder + + attr_accessor :voucher + + attr_accessor :campaign + + attr_accessor :reward_redemption + + attr_accessor :reward + + attr_accessor :reward_assignment + + attr_accessor :source + + attr_accessor :balance + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'holder' => :'holder', + :'voucher' => :'voucher', + :'campaign' => :'campaign', + :'reward_redemption' => :'reward_redemption', + :'reward' => :'reward', + :'reward_assignment' => :'reward_assignment', + :'source' => :'source', + :'balance' => :'balance' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'holder' => :'SimpleCustomer', + :'voucher' => :'SimpleVoucher', + :'campaign' => :'SimpleCampaign', + :'reward_redemption' => :'Object', + :'reward' => :'SimpleRedemptionRewardResult', + :'reward_assignment' => :'RewardAssignment', + :'source' => :'String', + :'balance' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRewardRedemptions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRewardRedemptionsPending` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRewardRedemptionsPending`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'reward_redemption') + self.reward_redemption = attributes[:'reward_redemption'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'reward_assignment') + self.reward_assignment = attributes[:'reward_assignment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + holder == o.holder && + voucher == o.voucher && + campaign == o.campaign && + reward_redemption == o.reward_redemption && + reward == o.reward && + reward_assignment == o.reward_assignment && + source == o.source && + balance == o.balance + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, holder, voucher, campaign, reward_redemption, reward, reward_assignment, source, balance].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_reward_redemptions_rolled_back.rb b/lib/VoucherifySdk/models/event_customer_reward_redemptions_rolled_back.rb new file mode 100644 index 00000000..50cf1078 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_reward_redemptions_rolled_back.rb @@ -0,0 +1,294 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.reward_redemptions.rolledback`. + class EventCustomerRewardRedemptionsRolledBack + attr_accessor :customer + + attr_accessor :holder + + attr_accessor :voucher + + attr_accessor :campaign + + attr_accessor :reward_redemption + + attr_accessor :reward + + attr_accessor :reward_assignment + + attr_accessor :source + + attr_accessor :balance + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'holder' => :'holder', + :'voucher' => :'voucher', + :'campaign' => :'campaign', + :'reward_redemption' => :'reward_redemption', + :'reward' => :'reward', + :'reward_assignment' => :'reward_assignment', + :'source' => :'source', + :'balance' => :'balance' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'holder' => :'SimpleCustomer', + :'voucher' => :'SimpleVoucher', + :'campaign' => :'SimpleCampaign', + :'reward_redemption' => :'Object', + :'reward' => :'SimpleRedemptionRewardResult', + :'reward_assignment' => :'RewardAssignment', + :'source' => :'String', + :'balance' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRewardRedemptions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRewardRedemptionsRolledBack` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRewardRedemptionsRolledBack`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'reward_redemption') + self.reward_redemption = attributes[:'reward_redemption'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'reward_assignment') + self.reward_assignment = attributes[:'reward_assignment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + holder == o.holder && + voucher == o.voucher && + campaign == o.campaign && + reward_redemption == o.reward_redemption && + reward == o.reward && + reward_assignment == o.reward_assignment && + source == o.source && + balance == o.balance + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, holder, voucher, campaign, reward_redemption, reward, reward_assignment, source, balance].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_rewarded.rb b/lib/VoucherifySdk/models/event_customer_rewarded.rb new file mode 100644 index 00000000..c14d8fb3 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_rewarded.rb @@ -0,0 +1,296 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.rewarded`. + class EventCustomerRewarded + attr_accessor :customer + + attr_accessor :holder + + attr_accessor :voucher + + attr_accessor :campaign + + attr_accessor :redemption + + attr_accessor :reward + + attr_accessor :referral_tier + + attr_accessor :balance + + attr_accessor :custom_event + + attr_accessor :customer_event + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'holder' => :'holder', + :'voucher' => :'voucher', + :'campaign' => :'campaign', + :'redemption' => :'redemption', + :'reward' => :'reward', + :'referral_tier' => :'referral_tier', + :'balance' => :'balance', + :'custom_event' => :'custom_event', + :'customer_event' => :'customer_event' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'holder' => :'SimpleCustomer', + :'voucher' => :'SimpleVoucher', + :'campaign' => :'SimpleCampaign', + :'redemption' => :'RedemptionInternal', + :'reward' => :'SimpleRedemptionRewardResult', + :'referral_tier' => :'SimpleReferralTier', + :'balance' => :'Integer', + :'custom_event' => :'CustomEvent', + :'customer_event' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRewarded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRewarded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'referral_tier') + self.referral_tier = attributes[:'referral_tier'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'customer_event') + self.customer_event = attributes[:'customer_event'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + holder == o.holder && + voucher == o.voucher && + campaign == o.campaign && + redemption == o.redemption && + reward == o.reward && + referral_tier == o.referral_tier && + balance == o.balance && + custom_event == o.custom_event && + customer_event == o.customer_event + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, holder, voucher, campaign, redemption, reward, referral_tier, balance, custom_event, customer_event].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_rewarded_loyalty_points.rb b/lib/VoucherifySdk/models/event_customer_rewarded_loyalty_points.rb new file mode 100644 index 00000000..cc4c0f9b --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_rewarded_loyalty_points.rb @@ -0,0 +1,287 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.rewarded.loyalty_points`. + class EventCustomerRewardedLoyaltyPoints + attr_accessor :customer + + attr_accessor :holder + + attr_accessor :voucher + + attr_accessor :campaign + + attr_accessor :loyalty_tier + + attr_accessor :earning_rule + + attr_accessor :balance + + attr_accessor :order + + attr_accessor :event + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'holder' => :'holder', + :'voucher' => :'voucher', + :'campaign' => :'campaign', + :'loyalty_tier' => :'loyalty_tier', + :'earning_rule' => :'earning_rule', + :'balance' => :'balance', + :'order' => :'order', + :'event' => :'event' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'holder' => :'SimpleCustomer', + :'voucher' => :'SimpleVoucher', + :'campaign' => :'SimpleCampaign', + :'loyalty_tier' => :'LoyaltyTier', + :'earning_rule' => :'EarningRule', + :'balance' => :'Integer', + :'order' => :'OrderCalculated', + :'event' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerRewardedLoyaltyPoints` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerRewardedLoyaltyPoints`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'loyalty_tier') + self.loyalty_tier = attributes[:'loyalty_tier'] + end + + if attributes.key?(:'earning_rule') + self.earning_rule = attributes[:'earning_rule'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'event') + self.event = attributes[:'event'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + holder == o.holder && + voucher == o.voucher && + campaign == o.campaign && + loyalty_tier == o.loyalty_tier && + earning_rule == o.earning_rule && + balance == o.balance && + order == o.order && + event == o.event + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, holder, voucher, campaign, loyalty_tier, earning_rule, balance, order, event].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_segment_entered.rb b/lib/VoucherifySdk/models/event_customer_segment_entered.rb new file mode 100644 index 00000000..057edf63 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_segment_entered.rb @@ -0,0 +1,238 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.segment.entered`. + class EventCustomerSegmentEntered + attr_accessor :customer + + attr_accessor :segment + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'segment' => :'segment' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'segment' => :'SimpleSegment' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerSegmentEntered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerSegmentEntered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + else + self.segment = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @segment.nil? + invalid_properties.push('invalid value for "segment", segment cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @customer.nil? + return false if @segment.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + segment == o.segment + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, segment].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_segment_left.rb b/lib/VoucherifySdk/models/event_customer_segment_left.rb new file mode 100644 index 00000000..cc7bb259 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_segment_left.rb @@ -0,0 +1,238 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.segment.left`. + class EventCustomerSegmentLeft + attr_accessor :customer + + attr_accessor :segment + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'segment' => :'segment' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'segment' => :'SimpleSegment' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerSegmentLeft` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerSegmentLeft`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + else + self.segment = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @segment.nil? + invalid_properties.push('invalid value for "segment", segment cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @customer.nil? + return false if @segment.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + segment == o.segment + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, segment].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_sent.rb b/lib/VoucherifySdk/models/event_customer_sent.rb new file mode 100644 index 00000000..9f241f9e --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_sent.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class EventCustomerSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_shopify_failed.rb b/lib/VoucherifySdk/models/event_customer_shopify_failed.rb new file mode 100644 index 00000000..cae45e78 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_shopify_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.shopify.failed`. + class EventCustomerShopifyFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerShopifyFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerShopifyFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_shopify_recovered.rb b/lib/VoucherifySdk/models/event_customer_shopify_recovered.rb new file mode 100644 index 00000000..cfc78488 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_shopify_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.shopify.recovered`. + class EventCustomerShopifyRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerShopifyRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerShopifyRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_shopify_sent.rb b/lib/VoucherifySdk/models/event_customer_shopify_sent.rb new file mode 100644 index 00000000..07ec10ec --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_shopify_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.shopify.sent`. + class EventCustomerShopifySent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerShopifySent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerShopifySent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_sms_failed.rb b/lib/VoucherifySdk/models/event_customer_sms_failed.rb new file mode 100644 index 00000000..3d6a792d --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_sms_failed.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.sms.failed`. + class EventCustomerSmsFailed + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution failed in ISO 8601 format. + attr_accessor :failed_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'failed_at' => :'failed_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'failed_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerFailed' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerSmsFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerSmsFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'failed_at') + self.failed_at = attributes[:'failed_at'] + else + self.failed_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @failed_at.nil? + invalid_properties.push('invalid value for "failed_at", failed_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @failed_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + failed_at == o.failed_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, failed_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_sms_recovered.rb b/lib/VoucherifySdk/models/event_customer_sms_recovered.rb new file mode 100644 index 00000000..7c4ebcd9 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_sms_recovered.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.sms.recovered`. + class EventCustomerSmsRecovered + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was recovered in ISO 8601 format. + attr_accessor :recovered_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'recovered_at' => :'recovered_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'recovered_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerRecovered' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerSmsRecovered` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerSmsRecovered`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'recovered_at') + self.recovered_at = attributes[:'recovered_at'] + else + self.recovered_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @recovered_at.nil? + invalid_properties.push('invalid value for "recovered_at", recovered_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @recovered_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + recovered_at == o.recovered_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, recovered_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_sms_sent.rb b/lib/VoucherifySdk/models/event_customer_sms_sent.rb new file mode 100644 index 00000000..15a28f1d --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_sms_sent.rb @@ -0,0 +1,248 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.sms.sent`. + class EventCustomerSmsSent + attr_accessor :customer + + attr_accessor :distribution + + # Timestamp representing the date and time when the distribution was sent in ISO 8601 format. + attr_accessor :sent_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'distribution' => :'distribution', + :'sent_at' => :'sent_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'distribution' => :'Object', + :'sent_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EventCustomerSent' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerSmsSent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerSmsSent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'distribution') + self.distribution = attributes[:'distribution'] + end + + if attributes.key?(:'sent_at') + self.sent_at = attributes[:'sent_at'] + else + self.sent_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @sent_at.nil? + invalid_properties.push('invalid value for "sent_at", sent_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @sent_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + distribution == o.distribution && + sent_at == o.sent_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, distribution, sent_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_updated.rb b/lib/VoucherifySdk/models/event_customer_updated.rb new file mode 100644 index 00000000..a8ce6106 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_updated.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.updated`. + class EventCustomerUpdated + attr_accessor :customer + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'CustomerWithSummaryLoyaltyReferrals' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerUpdated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerUpdated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_validation_failed.rb b/lib/VoucherifySdk/models/event_customer_validation_failed.rb new file mode 100644 index 00000000..4f448b01 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_validation_failed.rb @@ -0,0 +1,224 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.validation.failed`. + class EventCustomerValidationFailed + attr_accessor :customer + + attr_accessor :validation + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'validation' => :'validation' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'validation' => :'ValidationEntity' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerValidationFailed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerValidationFailed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'validation') + self.validation = attributes[:'validation'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + validation == o.validation + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, validation].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_validation_succeeded.rb b/lib/VoucherifySdk/models/event_customer_validation_succeeded.rb new file mode 100644 index 00000000..2c6b44c1 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_validation_succeeded.rb @@ -0,0 +1,224 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.validation.succeeded`. + class EventCustomerValidationSucceeded + attr_accessor :customer + + attr_accessor :validation + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'validation' => :'validation' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'validation' => :'ValidationEntity' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerValidationSucceeded` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerValidationSucceeded`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'validation') + self.validation = attributes[:'validation'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + validation == o.validation + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, validation].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_voucher_deleted.rb b/lib/VoucherifySdk/models/event_customer_voucher_deleted.rb new file mode 100644 index 00000000..d9734afb --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_voucher_deleted.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.voucher.deleted`. + class EventCustomerVoucherDeleted + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :voucher + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerVoucherDeleted` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerVoucherDeleted`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/event_customer_vouchers_loyalty_points_expired.rb b/lib/VoucherifySdk/models/event_customer_vouchers_loyalty_points_expired.rb new file mode 100644 index 00000000..8ebecb41 --- /dev/null +++ b/lib/VoucherifySdk/models/event_customer_vouchers_loyalty_points_expired.rb @@ -0,0 +1,262 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Event data object schema for `customer.voucher.loyalty_card.points_expired`. + class EventCustomerVouchersLoyaltyPointsExpired + attr_accessor :customer + + attr_accessor :campaign + + attr_accessor :voucher + + attr_accessor :points + + attr_accessor :buckets + + attr_accessor :transaction + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'campaign' => :'campaign', + :'voucher' => :'voucher', + :'points' => :'points', + :'buckets' => :'buckets', + :'transaction' => :'transaction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'campaign' => :'SimpleCampaign', + :'voucher' => :'SimpleVoucher', + :'points' => :'Integer', + :'buckets' => :'Array', + :'transaction' => :'VoucherTransaction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventCustomerVouchersLoyaltyPointsExpired` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventCustomerVouchersLoyaltyPointsExpired`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + + if attributes.key?(:'buckets') + if (value = attributes[:'buckets']).is_a?(Array) + self.buckets = value + end + end + + if attributes.key?(:'transaction') + self.transaction = attributes[:'transaction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + campaign == o.campaign && + voucher == o.voucher && + points == o.points && + buckets == o.buckets && + transaction == o.transaction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, campaign, voucher, points, buckets, transaction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/events_create_request_body.rb b/lib/VoucherifySdk/models/events_create_request_body.rb new file mode 100644 index 00000000..7667effd --- /dev/null +++ b/lib/VoucherifySdk/models/events_create_request_body.rb @@ -0,0 +1,295 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/events`. + class EventsCreateRequestBody + # Event name. This is the same name that you used to define a custom event in the **Dashboard** > **Project Settings** > **Event Schema**. + attr_accessor :event + + attr_accessor :customer + + attr_accessor :referral + + attr_accessor :loyalty + + # The metadata object stores all custom attributes assigned to the event. A set of key/value pairs that you can attach to an event object. It can be useful for storing additional information about the event in a structured format. Event metadata schema is defined in the **Dashboard** > **Project Settings** > **Event Schema** > **Edit particular event** > **Metadata property definition**. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event' => :'event', + :'customer' => :'customer', + :'referral' => :'referral', + :'loyalty' => :'loyalty', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event' => :'String', + :'customer' => :'Customer', + :'referral' => :'ClientEventsCreateRequestBodyReferral', + :'loyalty' => :'ClientEventsCreateRequestBodyLoyalty', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventsCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventsCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event') + self.event = attributes[:'event'] + else + self.event = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'referral') + self.referral = attributes[:'referral'] + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @event.nil? + invalid_properties.push('invalid value for "event", event cannot be nil.') + end + + if @event.to_s.length > 300 + invalid_properties.push('invalid value for "event", the character length must be smaller than or equal to 300.') + end + + if @event.to_s.length < 1 + invalid_properties.push('invalid value for "event", the character length must be great than or equal to 1.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @event.nil? + return false if @event.to_s.length > 300 + return false if @event.to_s.length < 1 + return false if @customer.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] event Value to be assigned + def event=(event) + if event.nil? + fail ArgumentError, 'event cannot be nil' + end + + if event.to_s.length > 300 + fail ArgumentError, 'invalid value for "event", the character length must be smaller than or equal to 300.' + end + + if event.to_s.length < 1 + fail ArgumentError, 'invalid value for "event", the character length must be great than or equal to 1.' + end + + @event = event + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event == o.event && + customer == o.customer && + referral == o.referral && + loyalty == o.loyalty && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event, customer, referral, loyalty, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/events_create_response_body.rb b/lib/VoucherifySdk/models/events_create_response_body.rb new file mode 100644 index 00000000..ce800c05 --- /dev/null +++ b/lib/VoucherifySdk/models/events_create_response_body.rb @@ -0,0 +1,316 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/events`. + class EventsCreateResponseBody + # The object represented is an `event`. + attr_accessor :object + + # The event name. + attr_accessor :type + + attr_accessor :customer + + # A `null` referral object. + attr_accessor :referral + + # A `null` loyalty object. + attr_accessor :loyalty + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'type' => :'type', + :'customer' => :'customer', + :'referral' => :'referral', + :'loyalty' => :'loyalty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'type' => :'String', + :'customer' => :'SimpleCustomerRequiredObjectType', + :'referral' => :'Object', + :'loyalty' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'referral', + :'loyalty' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::EventsCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::EventsCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'event' + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'referral') + self.referral = attributes[:'referral'] + else + self.referral = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["event"]) + return false unless object_validator.valid?(@object) + return false if @type.nil? + return false if @customer.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["event"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + type == o.type && + customer == o.customer && + referral == o.referral && + loyalty == o.loyalty + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, type, customer, referral, loyalty].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export.rb b/lib/VoucherifySdk/models/export.rb new file mode 100644 index 00000000..183b4fe5 --- /dev/null +++ b/lib/VoucherifySdk/models/export.rb @@ -0,0 +1,110 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module Export + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ExportCustomer', + :'ExportOrder', + :'ExportPointsExpiration', + :'ExportPublication', + :'ExportRedemption', + :'ExportVoucher', + :'ExportVoucherTransactions' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/export_base.rb b/lib/VoucherifySdk/models/export_base.rb new file mode 100644 index 00000000..ccae40a0 --- /dev/null +++ b/lib/VoucherifySdk/models/export_base.rb @@ -0,0 +1,354 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportBase + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_base_result.rb b/lib/VoucherifySdk/models/export_base_result.rb new file mode 100644 index 00000000..48222ed6 --- /dev/null +++ b/lib/VoucherifySdk/models/export_base_result.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the URL of the CSV file. + class ExportBaseResult + # URL of the CSV file location. It contains the token used for authorization in the Download export method. + attr_accessor :url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportBaseResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportBaseResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'url') + self.url = attributes[:'url'] + else + self.url = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @url.nil? + invalid_properties.push('invalid value for "url", url cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @url.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_customer.rb b/lib/VoucherifySdk/models/export_customer.rb new file mode 100644 index 00000000..684aef35 --- /dev/null +++ b/lib/VoucherifySdk/models/export_customer.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportCustomer + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportCustomerBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportBase', + :'ExportCustomerBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportCustomer` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportCustomer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'customer' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_customer_base.rb b/lib/VoucherifySdk/models/export_customer_base.rb new file mode 100644 index 00000000..ae2de4dc --- /dev/null +++ b/lib/VoucherifySdk/models/export_customer_base.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportCustomerBase + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exported_object' => :'String', + :'parameters' => :'ExportCustomerBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportCustomerBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportCustomerBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'customer' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_customer_base_parameters.rb b/lib/VoucherifySdk/models/export_customer_base_parameters.rb new file mode 100644 index 00000000..3da87d46 --- /dev/null +++ b/lib/VoucherifySdk/models/export_customer_base_parameters.rb @@ -0,0 +1,259 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with an order along with the sorting order of the returned data. + class ExportCustomerBaseParameters + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. + attr_accessor :fields + + # Allowed additional properties must start with \"metadata.\" or \"address.\" or \"summary.\" or \"loyalty.\" or \"loyalty_tier.\" or \"loyalty_points.\" or \"system_metadata.\" + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'ExportCustomerOrder', + :'fields' => :'Array', + :'filters' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportCustomerBaseParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportCustomerBaseParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_customer_fields.rb b/lib/VoucherifySdk/models/export_customer_fields.rb new file mode 100644 index 00000000..35fac2e8 --- /dev/null +++ b/lib/VoucherifySdk/models/export_customer_fields.rb @@ -0,0 +1,68 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportCustomerFields + NAME = "name".freeze + ID = "id".freeze + DESCRIPTION = "description".freeze + EMAIL = "email".freeze + SOURCE_ID = "source_id".freeze + CREATED_AT = "created_at".freeze + ADDRESS_CITY = "address_city".freeze + ADDRESS_STATE = "address_state".freeze + ADDRESS_LINE_1 = "address_line_1".freeze + ADDRESS_LINE_2 = "address_line_2".freeze + ADDRESS_COUNTRY = "address_country".freeze + ADDRESS_POSTAL_CODE = "address_postal_code".freeze + REDEMPTIONS_TOTAL_REDEEMED = "redemptions_total_redeemed".freeze + REDEMPTIONS_TOTAL_FAILED = "redemptions_total_failed".freeze + REDEMPTIONS_TOTAL_SUCCEEDED = "redemptions_total_succeeded".freeze + REDEMPTIONS_TOTAL_ROLLED_BACK = "redemptions_total_rolled_back".freeze + REDEMPTIONS_TOTAL_ROLLBACK_FAILED = "redemptions_total_rollback_failed".freeze + REDEMPTIONS_TOTAL_ROLLBACK_SUCCEEDED = "redemptions_total_rollback_succeeded".freeze + ORDERS_TOTAL_AMOUNT = "orders_total_amount".freeze + ORDERS_TOTAL_COUNT = "orders_total_count".freeze + ORDERS_AVERAGE_AMOUNT = "orders_average_amount".freeze + ORDERS_LAST_ORDER_AMOUNT = "orders_last_order_amount".freeze + ORDERS_LAST_ORDER_DATE = "orders_last_order_date".freeze + LOYALTY_POINTS = "loyalty_points".freeze + LOYALTY_REFERRED_CUSTOMERS = "loyalty_referred_customers".freeze + UPDATED_AT = "updated_at".freeze + PHONE = "phone".freeze + BIRTHDAY = "birthday".freeze + METADATA = "metadata".freeze + BIRTHDATE = "birthdate".freeze + + def self.all_vars + @all_vars ||= [NAME, ID, DESCRIPTION, EMAIL, SOURCE_ID, CREATED_AT, ADDRESS_CITY, ADDRESS_STATE, ADDRESS_LINE_1, ADDRESS_LINE_2, ADDRESS_COUNTRY, ADDRESS_POSTAL_CODE, REDEMPTIONS_TOTAL_REDEEMED, REDEMPTIONS_TOTAL_FAILED, REDEMPTIONS_TOTAL_SUCCEEDED, REDEMPTIONS_TOTAL_ROLLED_BACK, REDEMPTIONS_TOTAL_ROLLBACK_FAILED, REDEMPTIONS_TOTAL_ROLLBACK_SUCCEEDED, ORDERS_TOTAL_AMOUNT, ORDERS_TOTAL_COUNT, ORDERS_AVERAGE_AMOUNT, ORDERS_LAST_ORDER_AMOUNT, ORDERS_LAST_ORDER_DATE, LOYALTY_POINTS, LOYALTY_REFERRED_CUSTOMERS, UPDATED_AT, PHONE, BIRTHDAY, METADATA, BIRTHDATE].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportCustomerFields.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportCustomerFields" + end + end +end diff --git a/lib/VoucherifySdk/models/export_customer_order.rb b/lib/VoucherifySdk/models/export_customer_order.rb new file mode 100644 index 00000000..acab4777 --- /dev/null +++ b/lib/VoucherifySdk/models/export_customer_order.rb @@ -0,0 +1,50 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportCustomerOrder + NAME = "-name".freeze + NAME2 = "name".freeze + ID = "-id".freeze + ID2 = "id".freeze + EMAIL = "-email".freeze + EMAIL2 = "email".freeze + SOURCE_ID = "-source_id".freeze + SOURCE_ID2 = "source_id".freeze + CREATED_AT = "-created_at".freeze + CREATED_AT2 = "created_at".freeze + UPDATED_AT = "-updated_at".freeze + UPDATED_AT2 = "updated_at".freeze + + def self.all_vars + @all_vars ||= [NAME, NAME2, ID, ID2, EMAIL, EMAIL2, SOURCE_ID, SOURCE_ID2, CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportCustomerOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportCustomerOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/export_customer_scheduled.rb b/lib/VoucherifySdk/models/export_customer_scheduled.rb new file mode 100644 index 00000000..2e46f94b --- /dev/null +++ b/lib/VoucherifySdk/models/export_customer_scheduled.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportCustomerScheduled + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportCustomerBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportCustomerBase', + :'ExportScheduledBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportCustomerScheduled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportCustomerScheduled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'customer' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_order.rb b/lib/VoucherifySdk/models/export_order.rb new file mode 100644 index 00000000..8ddbb822 --- /dev/null +++ b/lib/VoucherifySdk/models/export_order.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportOrder + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'OrdersExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportBase', + :'ExportOrderBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportOrder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'order' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_order_base.rb b/lib/VoucherifySdk/models/export_order_base.rb new file mode 100644 index 00000000..7042aa2e --- /dev/null +++ b/lib/VoucherifySdk/models/export_order_base.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportOrderBase + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exported_object' => :'String', + :'parameters' => :'OrdersExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportOrderBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportOrderBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'order' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_order_fields.rb b/lib/VoucherifySdk/models/export_order_fields.rb new file mode 100644 index 00000000..e38855ea --- /dev/null +++ b/lib/VoucherifySdk/models/export_order_fields.rb @@ -0,0 +1,51 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportOrderFields + ID = "id".freeze + SOURCE_ID = "source_id".freeze + CREATED_AT = "created_at".freeze + UPDATED_AT = "updated_at".freeze + STATUS = "status".freeze + AMOUNT = "amount".freeze + DISCOUNT_AMOUNT = "discount_amount".freeze + ITEMS_DISCOUNT_AMOUNT = "items_discount_amount".freeze + TOTAL_DISCOUNT_AMOUNT = "total_discount_amount".freeze + TOTAL_AMOUNT = "total_amount".freeze + CUSTOMER_ID = "customer_id".freeze + REFERRER_ID = "referrer_id".freeze + METADATA = "metadata".freeze + + def self.all_vars + @all_vars ||= [ID, SOURCE_ID, CREATED_AT, UPDATED_AT, STATUS, AMOUNT, DISCOUNT_AMOUNT, ITEMS_DISCOUNT_AMOUNT, TOTAL_DISCOUNT_AMOUNT, TOTAL_AMOUNT, CUSTOMER_ID, REFERRER_ID, METADATA].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportOrderFields.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportOrderFields" + end + end +end diff --git a/lib/VoucherifySdk/models/export_order_order.rb b/lib/VoucherifySdk/models/export_order_order.rb new file mode 100644 index 00000000..4aba72d5 --- /dev/null +++ b/lib/VoucherifySdk/models/export_order_order.rb @@ -0,0 +1,44 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportOrderOrder + CREATED_AT = "-created_at".freeze + CREATED_AT2 = "created_at".freeze + UPDATED_AT = "-updated_at".freeze + UPDATED_AT2 = "updated_at".freeze + STATUS = "-status".freeze + STATUS2 = "status".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2, STATUS, STATUS2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportOrderOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportOrderOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/export_order_scheduled.rb b/lib/VoucherifySdk/models/export_order_scheduled.rb new file mode 100644 index 00000000..29f6b632 --- /dev/null +++ b/lib/VoucherifySdk/models/export_order_scheduled.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportOrderScheduled + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'OrdersExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportOrderBase', + :'ExportScheduledBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportOrderScheduled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportOrderScheduled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'order' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_points_expiration.rb b/lib/VoucherifySdk/models/export_points_expiration.rb new file mode 100644 index 00000000..2e0f8146 --- /dev/null +++ b/lib/VoucherifySdk/models/export_points_expiration.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPointsExpiration + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportPointsExpirationBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportBase', + :'ExportPointsExpirationBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPointsExpiration` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPointsExpiration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'points_expiration' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["points_expiration"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["points_expiration"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_points_expiration_base.rb b/lib/VoucherifySdk/models/export_points_expiration_base.rb new file mode 100644 index 00000000..f668670b --- /dev/null +++ b/lib/VoucherifySdk/models/export_points_expiration_base.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPointsExpirationBase + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exported_object' => :'String', + :'parameters' => :'ExportPointsExpirationBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPointsExpirationBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPointsExpirationBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'points_expiration' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["points_expiration"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["points_expiration"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_points_expiration_base_parameters.rb b/lib/VoucherifySdk/models/export_points_expiration_base_parameters.rb new file mode 100644 index 00000000..308513a3 --- /dev/null +++ b/lib/VoucherifySdk/models/export_points_expiration_base_parameters.rb @@ -0,0 +1,258 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with an order along with the sorting order of the returned data. + class ExportPointsExpirationBaseParameters + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. + attr_accessor :fields + + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'ExportPointsExpirationOrder', + :'fields' => :'Array', + :'filters' => :'ExportPointsExpirationFilters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPointsExpirationBaseParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPointsExpirationBaseParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_points_expiration_fields.rb b/lib/VoucherifySdk/models/export_points_expiration_fields.rb new file mode 100644 index 00000000..7bb68f70 --- /dev/null +++ b/lib/VoucherifySdk/models/export_points_expiration_fields.rb @@ -0,0 +1,44 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPointsExpirationFields + ID = "id".freeze + CAMPAIGN_ID = "campaign_id".freeze + VOUCHER_ID = "voucher_id".freeze + POINTS = "points".freeze + STATUS = "status".freeze + EXPIRES_AT = "expires_at".freeze + + def self.all_vars + @all_vars ||= [ID, CAMPAIGN_ID, VOUCHER_ID, POINTS, STATUS, EXPIRES_AT].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportPointsExpirationFields.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportPointsExpirationFields" + end + end +end diff --git a/lib/VoucherifySdk/models/export_points_expiration_filters.rb b/lib/VoucherifySdk/models/export_points_expiration_filters.rb new file mode 100644 index 00000000..69fe0669 --- /dev/null +++ b/lib/VoucherifySdk/models/export_points_expiration_filters.rb @@ -0,0 +1,254 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPointsExpirationFilters + attr_accessor :junction + + attr_accessor :campaign_id + + attr_accessor :voucher_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'junction' => :'junction', + :'campaign_id' => :'campaign_id', + :'voucher_id' => :'voucher_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'junction' => :'Junction', + :'campaign_id' => :'FieldConditions', + :'voucher_id' => :'FieldConditions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPointsExpirationFilters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPointsExpirationFilters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'voucher_id') + self.voucher_id = attributes[:'voucher_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + junction == o.junction && + campaign_id == o.campaign_id && + voucher_id == o.voucher_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [junction, campaign_id, voucher_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_points_expiration_order.rb b/lib/VoucherifySdk/models/export_points_expiration_order.rb new file mode 100644 index 00000000..7cfe07db --- /dev/null +++ b/lib/VoucherifySdk/models/export_points_expiration_order.rb @@ -0,0 +1,40 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPointsExpirationOrder + EXPIRES_AT = "-expires_at".freeze + EXPIRES_AT2 = "expires_at".freeze + + def self.all_vars + @all_vars ||= [EXPIRES_AT, EXPIRES_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportPointsExpirationOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportPointsExpirationOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/export_points_expiration_scheduled.rb b/lib/VoucherifySdk/models/export_points_expiration_scheduled.rb new file mode 100644 index 00000000..a0e59f93 --- /dev/null +++ b/lib/VoucherifySdk/models/export_points_expiration_scheduled.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPointsExpirationScheduled + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportPointsExpirationBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportPointsExpirationBase', + :'ExportScheduledBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPointsExpirationScheduled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPointsExpirationScheduled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'points_expiration' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["points_expiration"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["points_expiration"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_publication.rb b/lib/VoucherifySdk/models/export_publication.rb new file mode 100644 index 00000000..06d46e78 --- /dev/null +++ b/lib/VoucherifySdk/models/export_publication.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPublication + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportPublicationBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportBase', + :'ExportPublicationBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPublication` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPublication`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'publication' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_publication_base.rb b/lib/VoucherifySdk/models/export_publication_base.rb new file mode 100644 index 00000000..8f4d900e --- /dev/null +++ b/lib/VoucherifySdk/models/export_publication_base.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPublicationBase + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exported_object' => :'String', + :'parameters' => :'ExportPublicationBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPublicationBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPublicationBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'publication' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_publication_base_parameters.rb b/lib/VoucherifySdk/models/export_publication_base_parameters.rb new file mode 100644 index 00000000..3168ff1f --- /dev/null +++ b/lib/VoucherifySdk/models/export_publication_base_parameters.rb @@ -0,0 +1,259 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with an order along with the sorting order of the returned data. + class ExportPublicationBaseParameters + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. + attr_accessor :fields + + # Allowed additional properties must start with \"metadata.\" + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'ExportPublicationOrder', + :'fields' => :'Array', + :'filters' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPublicationBaseParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPublicationBaseParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_publication_fields.rb b/lib/VoucherifySdk/models/export_publication_fields.rb new file mode 100644 index 00000000..487554b1 --- /dev/null +++ b/lib/VoucherifySdk/models/export_publication_fields.rb @@ -0,0 +1,46 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPublicationFields + VOUCHER_CODE = "voucher_code".freeze + CUSTOMER_ID = "customer_id".freeze + CUSTOMER_SOURCE_ID = "customer_source_id".freeze + DATE = "date".freeze + CHANNEL = "channel".freeze + CAMPAIGN = "campaign".freeze + IS_WINNER = "is_winner".freeze + METADATA = "metadata".freeze + + def self.all_vars + @all_vars ||= [VOUCHER_CODE, CUSTOMER_ID, CUSTOMER_SOURCE_ID, DATE, CHANNEL, CAMPAIGN, IS_WINNER, METADATA].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportPublicationFields.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportPublicationFields" + end + end +end diff --git a/lib/VoucherifySdk/models/export_publication_order.rb b/lib/VoucherifySdk/models/export_publication_order.rb new file mode 100644 index 00000000..b0629f06 --- /dev/null +++ b/lib/VoucherifySdk/models/export_publication_order.rb @@ -0,0 +1,50 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPublicationOrder + ID = "-id".freeze + ID2 = "id".freeze + VOUCHER_CODE = "-voucher_code".freeze + VOUCHER_CODE2 = "voucher_code".freeze + TRACKING_ID = "-tracking_id".freeze + TRACKING_ID2 = "tracking_id".freeze + CUSTOMER_ID = "-customer_id".freeze + CUSTOMER_ID2 = "customer_id".freeze + CREATED_AT = "-created_at".freeze + CREATED_AT2 = "created_at".freeze + CHANNEL = "-channel".freeze + CHANNEL2 = "channel".freeze + + def self.all_vars + @all_vars ||= [ID, ID2, VOUCHER_CODE, VOUCHER_CODE2, TRACKING_ID, TRACKING_ID2, CUSTOMER_ID, CUSTOMER_ID2, CREATED_AT, CREATED_AT2, CHANNEL, CHANNEL2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportPublicationOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportPublicationOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/export_publication_scheduled.rb b/lib/VoucherifySdk/models/export_publication_scheduled.rb new file mode 100644 index 00000000..97a7fe6e --- /dev/null +++ b/lib/VoucherifySdk/models/export_publication_scheduled.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportPublicationScheduled + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportPublicationBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportPublicationBase', + :'ExportScheduledBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportPublicationScheduled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportPublicationScheduled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'publication' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_redemption.rb b/lib/VoucherifySdk/models/export_redemption.rb new file mode 100644 index 00000000..972d8841 --- /dev/null +++ b/lib/VoucherifySdk/models/export_redemption.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportRedemption + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportRedemptionBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportBase', + :'ExportRedemptionBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'redemption' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["redemption"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["redemption"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_redemption_base.rb b/lib/VoucherifySdk/models/export_redemption_base.rb new file mode 100644 index 00000000..8710cb0c --- /dev/null +++ b/lib/VoucherifySdk/models/export_redemption_base.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportRedemptionBase + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exported_object' => :'String', + :'parameters' => :'ExportRedemptionBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportRedemptionBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportRedemptionBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'redemption' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["redemption"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["redemption"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_redemption_base_parameters.rb b/lib/VoucherifySdk/models/export_redemption_base_parameters.rb new file mode 100644 index 00000000..649ee38b --- /dev/null +++ b/lib/VoucherifySdk/models/export_redemption_base_parameters.rb @@ -0,0 +1,259 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with an order along with the sorting order of the returned data. + class ExportRedemptionBaseParameters + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. + attr_accessor :fields + + # Allowed additional properties must start with \"metadata.\" + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'ExportRedemptionOrder', + :'fields' => :'Array', + :'filters' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportRedemptionBaseParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportRedemptionBaseParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_redemption_fields.rb b/lib/VoucherifySdk/models/export_redemption_fields.rb new file mode 100644 index 00000000..8a3f0576 --- /dev/null +++ b/lib/VoucherifySdk/models/export_redemption_fields.rb @@ -0,0 +1,55 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportRedemptionFields + ID = "id".freeze + OBJECT = "object".freeze + DATE = "date".freeze + VOUCHER_CODE = "voucher_code".freeze + CAMPAIGN = "campaign".freeze + PROMOTION_TIER_ID = "promotion_tier_id".freeze + CUSTOMER_ID = "customer_id".freeze + CUSTOMER_SOURCE_ID = "customer_source_id".freeze + CUSTOMER_NAME = "customer_name".freeze + TRACKING_ID = "tracking_id".freeze + ORDER_AMOUNT = "order_amount".freeze + GIFT_AMOUNT = "gift_amount".freeze + LOYALTY_POINTS = "loyalty_points".freeze + RESULT = "result".freeze + FAILURE_CODE = "failure_code".freeze + FAILURE_MESSAGE = "failure_message".freeze + METADATA = "metadata".freeze + + def self.all_vars + @all_vars ||= [ID, OBJECT, DATE, VOUCHER_CODE, CAMPAIGN, PROMOTION_TIER_ID, CUSTOMER_ID, CUSTOMER_SOURCE_ID, CUSTOMER_NAME, TRACKING_ID, ORDER_AMOUNT, GIFT_AMOUNT, LOYALTY_POINTS, RESULT, FAILURE_CODE, FAILURE_MESSAGE, METADATA].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportRedemptionFields.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportRedemptionFields" + end + end +end diff --git a/lib/VoucherifySdk/models/export_redemption_order.rb b/lib/VoucherifySdk/models/export_redemption_order.rb new file mode 100644 index 00000000..9a821731 --- /dev/null +++ b/lib/VoucherifySdk/models/export_redemption_order.rb @@ -0,0 +1,48 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportRedemptionOrder + ID = "-id".freeze + ID2 = "id".freeze + VOUCHER_CODE = "-voucher_code".freeze + VOUCHER_CODE2 = "voucher_code".freeze + TRACKING_ID = "-tracking_id".freeze + TRACKING_ID2 = "tracking_id".freeze + CUSTOMER_ID = "-customer_id".freeze + CUSTOMER_ID2 = "customer_id".freeze + CREATED_AT = "-created_at".freeze + CREATED_AT2 = "created_at".freeze + + def self.all_vars + @all_vars ||= [ID, ID2, VOUCHER_CODE, VOUCHER_CODE2, TRACKING_ID, TRACKING_ID2, CUSTOMER_ID, CUSTOMER_ID2, CREATED_AT, CREATED_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportRedemptionOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportRedemptionOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/export_redemption_scheduled.rb b/lib/VoucherifySdk/models/export_redemption_scheduled.rb new file mode 100644 index 00000000..64beb39f --- /dev/null +++ b/lib/VoucherifySdk/models/export_redemption_scheduled.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportRedemptionScheduled + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportRedemptionBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportRedemptionBase', + :'ExportScheduledBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportRedemptionScheduled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportRedemptionScheduled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'redemption' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["redemption"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["redemption"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_scheduled_base.rb b/lib/VoucherifySdk/models/export_scheduled_base.rb new file mode 100644 index 00000000..28af3beb --- /dev/null +++ b/lib/VoucherifySdk/models/export_scheduled_base.rb @@ -0,0 +1,359 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportScheduledBase + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportScheduledBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportScheduledBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher.rb b/lib/VoucherifySdk/models/export_voucher.rb new file mode 100644 index 00000000..9bf00319 --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucher + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportVoucherBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportBase', + :'ExportVoucherBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher_base.rb b/lib/VoucherifySdk/models/export_voucher_base.rb new file mode 100644 index 00000000..cc5649b7 --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_base.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherBase + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exported_object' => :'String', + :'parameters' => :'ExportVoucherBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucherBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucherBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher_base_parameters.rb b/lib/VoucherifySdk/models/export_voucher_base_parameters.rb new file mode 100644 index 00000000..2968ce8e --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_base_parameters.rb @@ -0,0 +1,258 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherBaseParameters + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. + attr_accessor :fields + + # Allowed additional properties must start with \"metadata.\" or \"redemption.\" + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'ExportVoucherOrder', + :'fields' => :'Array', + :'filters' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucherBaseParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucherBaseParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher_fields.rb b/lib/VoucherifySdk/models/export_voucher_fields.rb new file mode 100644 index 00000000..65a644e4 --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_fields.rb @@ -0,0 +1,68 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherFields + CODE = "code".freeze + VOUCHER_TYPE = "voucher_type".freeze + VALUE = "value".freeze + DISCOUNT_TYPE = "discount_type".freeze + CAMPAIGN = "campaign".freeze + CATEGORY = "category".freeze + START_DATE = "start_date".freeze + EXPIRATION_DATE = "expiration_date".freeze + GIFT_BALANCE = "gift_balance".freeze + LOYALTY_BALANCE = "loyalty_balance".freeze + REDEMPTION_QUANTITY = "redemption_quantity".freeze + REDEMPTION_COUNT = "redemption_count".freeze + ACTIVE = "active".freeze + QR_CODE = "qr_code".freeze + BAR_CODE = "bar_code".freeze + METADATA = "metadata".freeze + ID = "id".freeze + IS_REFERRAL_CODE = "is_referral_code".freeze + CREATED_AT = "created_at".freeze + UPDATED_AT = "updated_at".freeze + VALIDITY_TIMEFRAME_INTERVAL = "validity_timeframe_interval".freeze + VALIDITY_TIMEFRAME_DURATION = "validity_timeframe_duration".freeze + VALIDITY_DAY_OF_WEEK = "validity_day_of_week".freeze + DISCOUNT_AMOUNT_LIMIT = "discount_amount_limit".freeze + CAMPAIGN_ID = "campaign_id".freeze + ADDITIONAL_INFO = "additional_info".freeze + CUSTOMER_ID = "customer_id".freeze + DISCOUNT_UNIT_TYPE = "discount_unit_type".freeze + DISCOUNT_UNIT_EFFECT = "discount_unit_effect".freeze + CUSTOMER_SOURCE_ID = "customer_source_id".freeze + + def self.all_vars + @all_vars ||= [CODE, VOUCHER_TYPE, VALUE, DISCOUNT_TYPE, CAMPAIGN, CATEGORY, START_DATE, EXPIRATION_DATE, GIFT_BALANCE, LOYALTY_BALANCE, REDEMPTION_QUANTITY, REDEMPTION_COUNT, ACTIVE, QR_CODE, BAR_CODE, METADATA, ID, IS_REFERRAL_CODE, CREATED_AT, UPDATED_AT, VALIDITY_TIMEFRAME_INTERVAL, VALIDITY_TIMEFRAME_DURATION, VALIDITY_DAY_OF_WEEK, DISCOUNT_AMOUNT_LIMIT, CAMPAIGN_ID, ADDITIONAL_INFO, CUSTOMER_ID, DISCOUNT_UNIT_TYPE, DISCOUNT_UNIT_EFFECT, CUSTOMER_SOURCE_ID].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportVoucherFields.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportVoucherFields" + end + end +end diff --git a/lib/VoucherifySdk/models/export_voucher_order.rb b/lib/VoucherifySdk/models/export_voucher_order.rb new file mode 100644 index 00000000..322cd78f --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_order.rb @@ -0,0 +1,44 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherOrder + CREATED_AT = "-created_at".freeze + CREATED_AT2 = "created_at".freeze + UPDATED_AT = "-updated_at".freeze + UPDATED_AT2 = "updated_at".freeze + CODE = "-code".freeze + CODE2 = "code".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2, CODE, CODE2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportVoucherOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportVoucherOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/export_voucher_scheduled.rb b/lib/VoucherifySdk/models/export_voucher_scheduled.rb new file mode 100644 index 00000000..ddcebc54 --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_scheduled.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherScheduled + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'ExportVoucherBaseParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportScheduledBase', + :'ExportVoucherBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucherScheduled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucherScheduled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher_transactions.rb b/lib/VoucherifySdk/models/export_voucher_transactions.rb new file mode 100644 index 00000000..c9187d7b --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_transactions.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherTransactions + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'LoyaltiesMembersTransactionsExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportBase', + :'ExportVoucherTransactionsBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucherTransactions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucherTransactions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher_transactions' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher_transactions_base.rb b/lib/VoucherifySdk/models/export_voucher_transactions_base.rb new file mode 100644 index 00000000..e8542f47 --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_transactions_base.rb @@ -0,0 +1,265 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherTransactionsBase + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exported_object' => :'String', + :'parameters' => :'LoyaltiesMembersTransactionsExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucherTransactionsBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucherTransactionsBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher_transactions' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher_transactions_fields.rb b/lib/VoucherifySdk/models/export_voucher_transactions_fields.rb new file mode 100644 index 00000000..f0ae12cf --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_transactions_fields.rb @@ -0,0 +1,50 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherTransactionsFields + ID = "id".freeze + CAMPAIGN_ID = "campaign_id".freeze + VOUCHER_ID = "voucher_id".freeze + TYPE = "type".freeze + SOURCE_ID = "source_id".freeze + REASON = "reason".freeze + SOURCE = "source".freeze + BALANCE = "balance".freeze + AMOUNT = "amount".freeze + RELATED_TRANSACTION_ID = "related_transaction_id".freeze + CREATED_AT = "created_at".freeze + DETAILS = "details".freeze + + def self.all_vars + @all_vars ||= [ID, CAMPAIGN_ID, VOUCHER_ID, TYPE, SOURCE_ID, REASON, SOURCE, BALANCE, AMOUNT, RELATED_TRANSACTION_ID, CREATED_AT, DETAILS].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportVoucherTransactionsFields.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportVoucherTransactionsFields" + end + end +end diff --git a/lib/VoucherifySdk/models/export_voucher_transactions_filters.rb b/lib/VoucherifySdk/models/export_voucher_transactions_filters.rb new file mode 100644 index 00000000..830816fe --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_transactions_filters.rb @@ -0,0 +1,263 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherTransactionsFilters + attr_accessor :junction + + attr_accessor :created_at + + attr_accessor :voucher_id + + attr_accessor :campaign_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'junction' => :'junction', + :'created_at' => :'created_at', + :'voucher_id' => :'voucher_id', + :'campaign_id' => :'campaign_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'junction' => :'Junction', + :'created_at' => :'FieldConditions', + :'voucher_id' => :'FieldConditions', + :'campaign_id' => :'FieldConditions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucherTransactionsFilters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucherTransactionsFilters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'voucher_id') + self.voucher_id = attributes[:'voucher_id'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + junction == o.junction && + created_at == o.created_at && + voucher_id == o.voucher_id && + campaign_id == o.campaign_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [junction, created_at, voucher_id, campaign_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/export_voucher_transactions_order.rb b/lib/VoucherifySdk/models/export_voucher_transactions_order.rb new file mode 100644 index 00000000..c1f8a2d6 --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_transactions_order.rb @@ -0,0 +1,40 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherTransactionsOrder + CREATED_AT = "-created_at".freeze + CREATED_AT2 = "created_at".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExportVoucherTransactionsOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExportVoucherTransactionsOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/export_voucher_transactions_scheduled.rb b/lib/VoucherifySdk/models/export_voucher_transactions_scheduled.rb new file mode 100644 index 00000000..9f0d5479 --- /dev/null +++ b/lib/VoucherifySdk/models/export_voucher_transactions_scheduled.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ExportVoucherTransactionsScheduled + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'LoyaltiesMembersTransactionsExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportScheduledBase', + :'ExportVoucherTransactionsBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportVoucherTransactionsScheduled` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportVoucherTransactionsScheduled`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher_transactions' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/exports_create_request_body.rb b/lib/VoucherifySdk/models/exports_create_request_body.rb new file mode 100644 index 00000000..8cefd116 --- /dev/null +++ b/lib/VoucherifySdk/models/exports_create_request_body.rb @@ -0,0 +1,111 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/exports`. + module ExportsCreateRequestBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ExportCustomerBase', + :'ExportOrderBase', + :'ExportPointsExpirationBase', + :'ExportPublicationBase', + :'ExportRedemptionBase', + :'ExportVoucherBase', + :'ExportVoucherTransactionsBase' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/exports_create_response_body.rb b/lib/VoucherifySdk/models/exports_create_response_body.rb new file mode 100644 index 00000000..a98bc552 --- /dev/null +++ b/lib/VoucherifySdk/models/exports_create_response_body.rb @@ -0,0 +1,111 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/exports`. + module ExportsCreateResponseBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ExportCustomerScheduled', + :'ExportOrderScheduled', + :'ExportPointsExpirationScheduled', + :'ExportPublicationScheduled', + :'ExportRedemptionScheduled', + :'ExportVoucherScheduled', + :'ExportVoucherTransactionsScheduled' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/exports_get_response_body.rb b/lib/VoucherifySdk/models/exports_get_response_body.rb new file mode 100644 index 00000000..f0786d48 --- /dev/null +++ b/lib/VoucherifySdk/models/exports_get_response_body.rb @@ -0,0 +1,400 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/exports/{exportId}`. + class ExportsGetResponseBody + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'ExportBaseResult', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'LoyaltiesMembersTransactionsExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Export' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportsGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportsGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher_transactions' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + return false unless status_validator.valid?(@status) + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED", "IN_PROGRESS", "DONE", "ERROR"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/exports_list_response_body.rb b/lib/VoucherifySdk/models/exports_list_response_body.rb new file mode 100644 index 00000000..5702809c --- /dev/null +++ b/lib/VoucherifySdk/models/exports_list_response_body.rb @@ -0,0 +1,322 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/exports`. + class ExportsListResponseBody + # The type of object represented by JSON. This object stores information about exports. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of exports. + attr_accessor :data_ref + + # An array of export objects. + attr_accessor :exports + + # Total number of exports. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'exports' => :'exports', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'exports' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ExportsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ExportsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'exports' + end + + if attributes.key?(:'exports') + if (value = attributes[:'exports']).is_a?(Array) + self.exports = value + end + else + self.exports = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @exports.nil? + invalid_properties.push('invalid value for "exports", exports cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["exports"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @exports.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["exports"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + exports == o.exports && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, exports, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/field_conditions.rb b/lib/VoucherifySdk/models/field_conditions.rb new file mode 100644 index 00000000..8729aafd --- /dev/null +++ b/lib/VoucherifySdk/models/field_conditions.rb @@ -0,0 +1,214 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class FieldConditions + attr_accessor :conditions + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FiltersCondition' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::FieldConditions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::FieldConditions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/filter_conditions_string.rb b/lib/VoucherifySdk/models/filter_conditions_string.rb new file mode 100644 index 00000000..7a4a1fae --- /dev/null +++ b/lib/VoucherifySdk/models/filter_conditions_string.rb @@ -0,0 +1,290 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Data filters used to narrow the data records to be returned in the result. + class FilterConditionsString + # Array of resource values that should be included in the results. (multiple values) + attr_accessor :_in + + # Array of resource values that should be included in the results. (multiple values) + attr_accessor :not_in + + # Value is exactly this value. (single value) + attr_accessor :is + + # Results omit this value. (single value) + attr_accessor :is_not + + # Value is NOT null. The value for this parameter is an empty string. + attr_accessor :has_value + + # Value is null. The value for this parameter is an empty string. + attr_accessor :is_unknown + + # Value starts with the specified string. + attr_accessor :starts_with + + # Value ends with the specified string. + attr_accessor :ends_with + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_in' => :'$in', + :'not_in' => :'$not_in', + :'is' => :'$is', + :'is_not' => :'$is_not', + :'has_value' => :'$has_value', + :'is_unknown' => :'$is_unknown', + :'starts_with' => :'$starts_with', + :'ends_with' => :'$ends_with' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'_in' => :'Array', + :'not_in' => :'Array', + :'is' => :'String', + :'is_not' => :'String', + :'has_value' => :'String', + :'is_unknown' => :'String', + :'starts_with' => :'String', + :'ends_with' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::FilterConditionsString` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::FilterConditionsString`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'_in') + if (value = attributes[:'_in']).is_a?(Array) + self._in = value + end + end + + if attributes.key?(:'not_in') + if (value = attributes[:'not_in']).is_a?(Array) + self.not_in = value + end + end + + if attributes.key?(:'is') + self.is = attributes[:'is'] + end + + if attributes.key?(:'is_not') + self.is_not = attributes[:'is_not'] + end + + if attributes.key?(:'has_value') + self.has_value = attributes[:'has_value'] + end + + if attributes.key?(:'is_unknown') + self.is_unknown = attributes[:'is_unknown'] + end + + if attributes.key?(:'starts_with') + self.starts_with = attributes[:'starts_with'] + end + + if attributes.key?(:'ends_with') + self.ends_with = attributes[:'ends_with'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _in == o._in && + not_in == o.not_in && + is == o.is && + is_not == o.is_not && + has_value == o.has_value && + is_unknown == o.is_unknown && + starts_with == o.starts_with && + ends_with == o.ends_with + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [_in, not_in, is, is_not, has_value, is_unknown, starts_with, ends_with].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/filters_condition.rb b/lib/VoucherifySdk/models/filters_condition.rb new file mode 100644 index 00000000..15db1c4a --- /dev/null +++ b/lib/VoucherifySdk/models/filters_condition.rb @@ -0,0 +1,430 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class FiltersCondition + attr_accessor :_in + + attr_accessor :not_in + + attr_accessor :is + + attr_accessor :is_days_ago + + attr_accessor :is_days_in_future + + attr_accessor :is_not + + attr_accessor :has_value + + attr_accessor :is_unknown + + attr_accessor :contains + + attr_accessor :not_contain + + attr_accessor :starts_with + + attr_accessor :ends_with + + attr_accessor :more_than + + attr_accessor :less_than + + attr_accessor :more_than_ago + + attr_accessor :less_than_ago + + attr_accessor :more_than_future + + attr_accessor :less_than_future + + attr_accessor :more_than_equal + + attr_accessor :less_than_equal + + attr_accessor :after + + attr_accessor :before + + attr_accessor :count + + attr_accessor :count_less + + attr_accessor :count_more + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_in' => :'$in', + :'not_in' => :'$not_in', + :'is' => :'$is', + :'is_days_ago' => :'$is_days_ago', + :'is_days_in_future' => :'$is_days_in_future', + :'is_not' => :'$is_not', + :'has_value' => :'$has_value', + :'is_unknown' => :'$is_unknown', + :'contains' => :'$contains', + :'not_contain' => :'$not_contain', + :'starts_with' => :'$starts_with', + :'ends_with' => :'$ends_with', + :'more_than' => :'$more_than', + :'less_than' => :'$less_than', + :'more_than_ago' => :'$more_than_ago', + :'less_than_ago' => :'$less_than_ago', + :'more_than_future' => :'$more_than_future', + :'less_than_future' => :'$less_than_future', + :'more_than_equal' => :'$more_than_equal', + :'less_than_equal' => :'$less_than_equal', + :'after' => :'$after', + :'before' => :'$before', + :'count' => :'$count', + :'count_less' => :'$count_less', + :'count_more' => :'$count_more' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'_in' => :'Any', + :'not_in' => :'Any', + :'is' => :'Any', + :'is_days_ago' => :'Any', + :'is_days_in_future' => :'Any', + :'is_not' => :'Any', + :'has_value' => :'Any', + :'is_unknown' => :'Any', + :'contains' => :'Any', + :'not_contain' => :'Any', + :'starts_with' => :'Any', + :'ends_with' => :'Any', + :'more_than' => :'Any', + :'less_than' => :'Any', + :'more_than_ago' => :'Any', + :'less_than_ago' => :'Any', + :'more_than_future' => :'Any', + :'less_than_future' => :'Any', + :'more_than_equal' => :'Any', + :'less_than_equal' => :'Any', + :'after' => :'Any', + :'before' => :'Any', + :'count' => :'Any', + :'count_less' => :'Any', + :'count_more' => :'Any' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::FiltersCondition` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::FiltersCondition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'_in') + self._in = attributes[:'_in'] + end + + if attributes.key?(:'not_in') + self.not_in = attributes[:'not_in'] + end + + if attributes.key?(:'is') + self.is = attributes[:'is'] + end + + if attributes.key?(:'is_days_ago') + self.is_days_ago = attributes[:'is_days_ago'] + end + + if attributes.key?(:'is_days_in_future') + self.is_days_in_future = attributes[:'is_days_in_future'] + end + + if attributes.key?(:'is_not') + self.is_not = attributes[:'is_not'] + end + + if attributes.key?(:'has_value') + self.has_value = attributes[:'has_value'] + end + + if attributes.key?(:'is_unknown') + self.is_unknown = attributes[:'is_unknown'] + end + + if attributes.key?(:'contains') + self.contains = attributes[:'contains'] + end + + if attributes.key?(:'not_contain') + self.not_contain = attributes[:'not_contain'] + end + + if attributes.key?(:'starts_with') + self.starts_with = attributes[:'starts_with'] + end + + if attributes.key?(:'ends_with') + self.ends_with = attributes[:'ends_with'] + end + + if attributes.key?(:'more_than') + self.more_than = attributes[:'more_than'] + end + + if attributes.key?(:'less_than') + self.less_than = attributes[:'less_than'] + end + + if attributes.key?(:'more_than_ago') + self.more_than_ago = attributes[:'more_than_ago'] + end + + if attributes.key?(:'less_than_ago') + self.less_than_ago = attributes[:'less_than_ago'] + end + + if attributes.key?(:'more_than_future') + self.more_than_future = attributes[:'more_than_future'] + end + + if attributes.key?(:'less_than_future') + self.less_than_future = attributes[:'less_than_future'] + end + + if attributes.key?(:'more_than_equal') + self.more_than_equal = attributes[:'more_than_equal'] + end + + if attributes.key?(:'less_than_equal') + self.less_than_equal = attributes[:'less_than_equal'] + end + + if attributes.key?(:'after') + self.after = attributes[:'after'] + end + + if attributes.key?(:'before') + self.before = attributes[:'before'] + end + + if attributes.key?(:'count') + self.count = attributes[:'count'] + end + + if attributes.key?(:'count_less') + self.count_less = attributes[:'count_less'] + end + + if attributes.key?(:'count_more') + self.count_more = attributes[:'count_more'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _in == o._in && + not_in == o.not_in && + is == o.is && + is_days_ago == o.is_days_ago && + is_days_in_future == o.is_days_in_future && + is_not == o.is_not && + has_value == o.has_value && + is_unknown == o.is_unknown && + contains == o.contains && + not_contain == o.not_contain && + starts_with == o.starts_with && + ends_with == o.ends_with && + more_than == o.more_than && + less_than == o.less_than && + more_than_ago == o.more_than_ago && + less_than_ago == o.less_than_ago && + more_than_future == o.more_than_future && + less_than_future == o.less_than_future && + more_than_equal == o.more_than_equal && + less_than_equal == o.less_than_equal && + after == o.after && + before == o.before && + count == o.count && + count_less == o.count_less && + count_more == o.count_more + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [_in, not_in, is, is_days_ago, is_days_in_future, is_not, has_value, is_unknown, contains, not_contain, starts_with, ends_with, more_than, less_than, more_than_ago, less_than_ago, more_than_future, less_than_future, more_than_equal, less_than_equal, after, before, count, count_less, count_more].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/gift.rb b/lib/VoucherifySdk/models/gift.rb new file mode 100644 index 00000000..f4df7500 --- /dev/null +++ b/lib/VoucherifySdk/models/gift.rb @@ -0,0 +1,284 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains current gift card balance information. + class Gift + # Total gift card income over the lifetime of the card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :amount + + # Available funds. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :balance + + # Defines how the credits are applied to the customer's order. + attr_accessor :effect + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'balance' => :'balance', + :'effect' => :'effect' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Float', + :'balance' => :'Float', + :'effect' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Gift` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Gift`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + else + self.balance = nil + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + if @balance.nil? + invalid_properties.push('invalid value for "balance", balance cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @amount.nil? + return false if @balance.nil? + effect_validator = EnumAttributeValidator.new('String', ["APPLY_TO_ORDER", "APPLY_TO_ITEMS"]) + return false unless effect_validator.valid?(@effect) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] effect Object to be assigned + def effect=(effect) + validator = EnumAttributeValidator.new('String', ["APPLY_TO_ORDER", "APPLY_TO_ITEMS"]) + unless validator.valid?(effect) + fail ArgumentError, "invalid value for \"effect\", must be one of #{validator.allowable_values}." + end + @effect = effect + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + balance == o.balance && + effect == o.effect + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, balance, effect].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/gift_campaign_voucher.rb b/lib/VoucherifySdk/models/gift_campaign_voucher.rb new file mode 100644 index 00000000..e003e886 --- /dev/null +++ b/lib/VoucherifySdk/models/gift_campaign_voucher.rb @@ -0,0 +1,291 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema model for a discount voucher. + class GiftCampaignVoucher + # Type of voucher. + attr_accessor :type + + attr_accessor :gift + + attr_accessor :redemption + + attr_accessor :code_config + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'gift' => :'gift', + :'redemption' => :'redemption', + :'code_config' => :'code_config' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'gift' => :'Gift', + :'redemption' => :'CampaignLoyaltyVoucherRedemption', + :'code_config' => :'CodeConfig' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::GiftCampaignVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::GiftCampaignVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'GIFT_VOUCHER' + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + else + self.gift = nil + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'code_config') + self.code_config = attributes[:'code_config'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @gift.nil? + invalid_properties.push('invalid value for "gift", gift cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER"]) + return false unless type_validator.valid?(@type) + return false if @gift.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + gift == o.gift && + redemption == o.redemption && + code_config == o.code_config + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, gift, redemption, code_config].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/giveaway_campaign_voucher.rb b/lib/VoucherifySdk/models/giveaway_campaign_voucher.rb new file mode 100644 index 00000000..b0076437 --- /dev/null +++ b/lib/VoucherifySdk/models/giveaway_campaign_voucher.rb @@ -0,0 +1,300 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class GiveawayCampaignVoucher + # Type of voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :code_config + + attr_accessor :redemption + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'discount' => :'discount', + :'code_config' => :'code_config', + :'redemption' => :'redemption', + :'is_referral_code' => :'is_referral_code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'discount' => :'Discount', + :'code_config' => :'CodeConfig', + :'redemption' => :'CampaignLoyaltyVoucherRedemption', + :'is_referral_code' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::GiveawayCampaignVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::GiveawayCampaignVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'DISCOUNT_VOUCHER' + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + else + self.discount = nil + end + + if attributes.key?(:'code_config') + self.code_config = attributes[:'code_config'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @discount.nil? + invalid_properties.push('invalid value for "discount", discount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER"]) + return false unless type_validator.valid?(@type) + return false if @discount.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + discount == o.discount && + code_config == o.code_config && + redemption == o.redemption && + is_referral_code == o.is_referral_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, discount, code_config, redemption, is_referral_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/inapplicable_to.rb b/lib/VoucherifySdk/models/inapplicable_to.rb new file mode 100644 index 00000000..be787466 --- /dev/null +++ b/lib/VoucherifySdk/models/inapplicable_to.rb @@ -0,0 +1,413 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class InapplicableTo + # This object stores information about the product collection. + attr_accessor :object + + # Unique product collection ID assigned by Voucherify. + attr_accessor :id + + # The source ID from your inventory system. + attr_accessor :source_id + + # Parent product's unique ID assigned by Voucherify. + attr_accessor :product_id + + # Parent product's source ID from your inventory system. + attr_accessor :product_source_id + + attr_accessor :strict + + # New fixed price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 price is written as 1000. In case of the fixed price being calculated by the formula, i.e. the price_formula parameter is present in the fixed price definition, this value becomes the fallback value. Such that in a case where the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed price. + attr_accessor :price + + # Formula used to calculate the discounted price of an item. + attr_accessor :price_formula + + attr_accessor :effect + + # The maximum number of units allowed to be discounted per order line item. + attr_accessor :quantity_limit + + # The maximum number of units allowed to be discounted combined across all matched order line items. + attr_accessor :aggregated_quantity_limit + + # Upper limit allowed to be applied as a discount per order line item. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600. + attr_accessor :amount_limit + + # Maximum discount amount per order. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount on the entire order is written as 600. This value is definable for the following discount effects: - `APPLY_TO_ITEMS` (each item subtotal is discounted equally) - `APPLY_TO_ITEMS_BY_QUANTITY` (each unit of matched products has the same discount value) + attr_accessor :aggregated_amount_limit + + attr_accessor :order_item_indices + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'product_source_id' => :'product_source_id', + :'strict' => :'strict', + :'price' => :'price', + :'price_formula' => :'price_formula', + :'effect' => :'effect', + :'quantity_limit' => :'quantity_limit', + :'aggregated_quantity_limit' => :'aggregated_quantity_limit', + :'amount_limit' => :'amount_limit', + :'aggregated_amount_limit' => :'aggregated_amount_limit', + :'order_item_indices' => :'order_item_indices' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'product_source_id' => :'String', + :'strict' => :'Boolean', + :'price' => :'Float', + :'price_formula' => :'Float', + :'effect' => :'ApplicableToEffect', + :'quantity_limit' => :'Integer', + :'aggregated_quantity_limit' => :'Integer', + :'amount_limit' => :'Integer', + :'aggregated_amount_limit' => :'Integer', + :'order_item_indices' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ApplicableTo' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::InapplicableTo` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::InapplicableTo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'product_source_id') + self.product_source_id = attributes[:'product_source_id'] + end + + if attributes.key?(:'strict') + self.strict = attributes[:'strict'] + else + self.strict = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'price_formula') + self.price_formula = attributes[:'price_formula'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + else + self.effect = nil + end + + if attributes.key?(:'quantity_limit') + self.quantity_limit = attributes[:'quantity_limit'] + end + + if attributes.key?(:'aggregated_quantity_limit') + self.aggregated_quantity_limit = attributes[:'aggregated_quantity_limit'] + end + + if attributes.key?(:'amount_limit') + self.amount_limit = attributes[:'amount_limit'] + end + + if attributes.key?(:'aggregated_amount_limit') + self.aggregated_amount_limit = attributes[:'aggregated_amount_limit'] + end + + if attributes.key?(:'order_item_indices') + if (value = attributes[:'order_item_indices']).is_a?(Array) + self.order_item_indices = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @strict.nil? + invalid_properties.push('invalid value for "strict", strict cannot be nil.') + end + + if @effect.nil? + invalid_properties.push('invalid value for "effect", effect cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product", "sku", "products_collection"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + return false if @strict.nil? + return false if @effect.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product", "sku", "products_collection"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + product_source_id == o.product_source_id && + strict == o.strict && + price == o.price && + price_formula == o.price_formula && + effect == o.effect && + quantity_limit == o.quantity_limit && + aggregated_quantity_limit == o.aggregated_quantity_limit && + amount_limit == o.amount_limit && + aggregated_amount_limit == o.aggregated_amount_limit && + order_item_indices == o.order_item_indices + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, id, source_id, product_id, product_source_id, strict, price, price_formula, effect, quantity_limit, aggregated_quantity_limit, amount_limit, aggregated_amount_limit, order_item_indices].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/inapplicable_to_result_list.rb b/lib/VoucherifySdk/models/inapplicable_to_result_list.rb new file mode 100644 index 00000000..7c387f84 --- /dev/null +++ b/lib/VoucherifySdk/models/inapplicable_to_result_list.rb @@ -0,0 +1,340 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class InapplicableToResultList + # Contains array of items to which the discount cannot apply. + attr_accessor :data + + # Total number of objects defining included products, SKUs, or product collections. + attr_accessor :total + + # The type of object represented by JSON. + attr_accessor :object + + # The type of object represented by JSON. + attr_accessor :data_ref + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'total' => :'total', + :'object' => :'object', + :'data_ref' => :'data_ref' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'total' => :'Integer', + :'object' => :'String', + :'data_ref' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::InapplicableToResultList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::InapplicableToResultList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @total < 0 + invalid_properties.push('invalid value for "total", must be greater than or equal to 0.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @data.nil? + return false if @total.nil? + return false if @total < 0 + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + true + end + + # Custom attribute writer method with validation + # @param [Object] total Value to be assigned + def total=(total) + if total.nil? + fail ArgumentError, 'total cannot be nil' + end + + if total < 0 + fail ArgumentError, 'invalid value for "total", must be greater than or equal to 0.' + end + + @total = total + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + total == o.total && + object == o.object && + data_ref == o.data_ref + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, total, object, data_ref].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/junction.rb b/lib/VoucherifySdk/models/junction.rb new file mode 100644 index 00000000..41d602b0 --- /dev/null +++ b/lib/VoucherifySdk/models/junction.rb @@ -0,0 +1,40 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class Junction + AND = "and".freeze + OR = "or".freeze + + def self.all_vars + @all_vars ||= [AND, OR].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if Junction.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #Junction" + end + end +end diff --git a/lib/VoucherifySdk/models/list_publications_item_base.rb b/lib/VoucherifySdk/models/list_publications_item_base.rb new file mode 100644 index 00000000..3014ca30 --- /dev/null +++ b/lib/VoucherifySdk/models/list_publications_item_base.rb @@ -0,0 +1,399 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ListPublicationsItemBase + # Unique publication ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `publication`. + attr_accessor :object + + # Timestamp representing the date and time when the publication was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer receiving the publication. + attr_accessor :customer_id + + # Customer's `source_id`. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # How the publication was originated. It can be your own custom channel or an example value provided here. + attr_accessor :channel + + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + attr_accessor :customer + + # Contains the unique internal voucher ID that was assigned by Voucherify. + attr_accessor :vouchers_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel' => :'channel', + :'source_id' => :'source_id', + :'customer' => :'customer', + :'vouchers_id' => :'vouchers_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel' => :'String', + :'source_id' => :'String', + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'vouchers_id' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ListPublicationsItemBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ListPublicationsItemBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'publication' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'vouchers_id') + if (value = attributes[:'vouchers_id']).is_a?(Array) + self.vouchers_id = value + end + else + self.vouchers_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @vouchers_id.nil? + invalid_properties.push('invalid value for "vouchers_id", vouchers_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @customer_id.nil? + return false if @metadata.nil? + return false if @channel.nil? + return false if @customer.nil? + return false if @vouchers_id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel == o.channel && + source_id == o.source_id && + customer == o.customer && + vouchers_id == o.vouchers_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, customer_id, tracking_id, metadata, channel, source_id, customer, vouchers_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/list_publications_item_invalid.rb b/lib/VoucherifySdk/models/list_publications_item_invalid.rb new file mode 100644 index 00000000..8bc400b9 --- /dev/null +++ b/lib/VoucherifySdk/models/list_publications_item_invalid.rb @@ -0,0 +1,455 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ListPublicationsItemInvalid + # Unique publication ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `publication`. + attr_accessor :object + + # Timestamp representing the date and time when the publication was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer receiving the publication. + attr_accessor :customer_id + + # Customer's `source_id`. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # How the publication was originated. It can be your own custom channel or an example value provided here. + attr_accessor :channel + + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + attr_accessor :customer + + # Contains the unique internal voucher ID that was assigned by Voucherify. + attr_accessor :vouchers_id + + # Status of the publication attempt. + attr_accessor :result + + # Generic reason as to why the create publication operation failed. + attr_accessor :failure_code + + # This parameter will provide more expanded reason as to why the create publication operation failed. + attr_accessor :failure_message + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel' => :'channel', + :'source_id' => :'source_id', + :'customer' => :'customer', + :'vouchers_id' => :'vouchers_id', + :'result' => :'result', + :'failure_code' => :'failure_code', + :'failure_message' => :'failure_message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel' => :'String', + :'source_id' => :'String', + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'vouchers_id' => :'Array', + :'result' => :'String', + :'failure_code' => :'String', + :'failure_message' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ListPublicationsItemBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ListPublicationsItemInvalid` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ListPublicationsItemInvalid`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'publication' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'vouchers_id') + if (value = attributes[:'vouchers_id']).is_a?(Array) + self.vouchers_id = value + end + else + self.vouchers_id = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = 'FAILURE' + end + + if attributes.key?(:'failure_code') + self.failure_code = attributes[:'failure_code'] + end + + if attributes.key?(:'failure_message') + self.failure_message = attributes[:'failure_message'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @vouchers_id.nil? + invalid_properties.push('invalid value for "vouchers_id", vouchers_id cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @customer_id.nil? + return false if @metadata.nil? + return false if @channel.nil? + return false if @customer.nil? + return false if @vouchers_id.nil? + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["FAILURE"]) + return false unless result_validator.valid?(@result) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["FAILURE"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel == o.channel && + source_id == o.source_id && + customer == o.customer && + vouchers_id == o.vouchers_id && + result == o.result && + failure_code == o.failure_code && + failure_message == o.failure_message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, customer_id, tracking_id, metadata, channel, source_id, customer, vouchers_id, result, failure_code, failure_message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/list_publications_item_valid_multiple_vouchers.rb b/lib/VoucherifySdk/models/list_publications_item_valid_multiple_vouchers.rb new file mode 100644 index 00000000..5544e929 --- /dev/null +++ b/lib/VoucherifySdk/models/list_publications_item_valid_multiple_vouchers.rb @@ -0,0 +1,454 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ListPublicationsItemValidMultipleVouchers + # Unique publication ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `publication`. + attr_accessor :object + + # Timestamp representing the date and time when the publication was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer receiving the publication. + attr_accessor :customer_id + + # Customer's `source_id`. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # How the publication was originated. It can be your own custom channel or an example value provided here. + attr_accessor :channel + + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + attr_accessor :customer + + # Contains the unique internal voucher ID that was assigned by Voucherify. + attr_accessor :vouchers_id + + # Status of the publication attempt. + attr_accessor :result + + # Contains the unique voucher codes that was assigned by Voucherify. + attr_accessor :vouchers + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel' => :'channel', + :'source_id' => :'source_id', + :'customer' => :'customer', + :'vouchers_id' => :'vouchers_id', + :'result' => :'result', + :'vouchers' => :'vouchers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel' => :'String', + :'source_id' => :'String', + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'vouchers_id' => :'Array', + :'result' => :'String', + :'vouchers' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ListPublicationsItemBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ListPublicationsItemValidMultipleVouchers` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ListPublicationsItemValidMultipleVouchers`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'publication' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'vouchers_id') + if (value = attributes[:'vouchers_id']).is_a?(Array) + self.vouchers_id = value + end + else + self.vouchers_id = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = 'SUCCESS' + end + + if attributes.key?(:'vouchers') + if (value = attributes[:'vouchers']).is_a?(Array) + self.vouchers = value + end + else + self.vouchers = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @vouchers_id.nil? + invalid_properties.push('invalid value for "vouchers_id", vouchers_id cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @vouchers.nil? + invalid_properties.push('invalid value for "vouchers", vouchers cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @customer_id.nil? + return false if @metadata.nil? + return false if @channel.nil? + return false if @customer.nil? + return false if @vouchers_id.nil? + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + return false unless result_validator.valid?(@result) + return false if @vouchers.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel == o.channel && + source_id == o.source_id && + customer == o.customer && + vouchers_id == o.vouchers_id && + result == o.result && + vouchers == o.vouchers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, customer_id, tracking_id, metadata, channel, source_id, customer, vouchers_id, result, vouchers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/list_publications_item_valid_single_voucher.rb b/lib/VoucherifySdk/models/list_publications_item_valid_single_voucher.rb new file mode 100644 index 00000000..45ddbe46 --- /dev/null +++ b/lib/VoucherifySdk/models/list_publications_item_valid_single_voucher.rb @@ -0,0 +1,451 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ListPublicationsItemValidSingleVoucher + # Unique publication ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `publication`. + attr_accessor :object + + # Timestamp representing the date and time when the publication was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer receiving the publication. + attr_accessor :customer_id + + # Customer's `source_id`. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # How the publication was originated. It can be your own custom channel or an example value provided here. + attr_accessor :channel + + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + attr_accessor :customer + + # Contains the unique internal voucher ID that was assigned by Voucherify. + attr_accessor :vouchers_id + + # Status of the publication attempt. + attr_accessor :result + + attr_accessor :voucher + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel' => :'channel', + :'source_id' => :'source_id', + :'customer' => :'customer', + :'vouchers_id' => :'vouchers_id', + :'result' => :'result', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel' => :'String', + :'source_id' => :'String', + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'vouchers_id' => :'Array', + :'result' => :'String', + :'voucher' => :'ListPublicationsItemVoucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ListPublicationsItemBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ListPublicationsItemValidSingleVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ListPublicationsItemValidSingleVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'publication' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'vouchers_id') + if (value = attributes[:'vouchers_id']).is_a?(Array) + self.vouchers_id = value + end + else + self.vouchers_id = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = 'SUCCESS' + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + else + self.voucher = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @vouchers_id.nil? + invalid_properties.push('invalid value for "vouchers_id", vouchers_id cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @voucher.nil? + invalid_properties.push('invalid value for "voucher", voucher cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @customer_id.nil? + return false if @metadata.nil? + return false if @channel.nil? + return false if @customer.nil? + return false if @vouchers_id.nil? + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + return false unless result_validator.valid?(@result) + return false if @voucher.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel == o.channel && + source_id == o.source_id && + customer == o.customer && + vouchers_id == o.vouchers_id && + result == o.result && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, customer_id, tracking_id, metadata, channel, source_id, customer, vouchers_id, result, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/list_publications_item_voucher.rb b/lib/VoucherifySdk/models/list_publications_item_voucher.rb new file mode 100644 index 00000000..382ce306 --- /dev/null +++ b/lib/VoucherifySdk/models/list_publications_item_voucher.rb @@ -0,0 +1,328 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ListPublicationsItemVoucher + # Voucher code. + attr_accessor :code + + # The type of object represented by JSON. + attr_accessor :object + + # Campaign name + attr_accessor :campaign + + attr_accessor :gift + + # Defines the loyalty card details. + attr_accessor :loyalty_card + + attr_accessor :discount + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'object' => :'object', + :'campaign' => :'campaign', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'discount' => :'discount', + :'is_referral_code' => :'is_referral_code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'String', + :'object' => :'String', + :'campaign' => :'String', + :'gift' => :'Gift', + :'loyalty_card' => :'Object', + :'discount' => :'Discount', + :'is_referral_code' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ListPublicationsItemVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ListPublicationsItemVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + else + self.campaign = nil + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @campaign.nil? + invalid_properties.push('invalid value for "campaign", campaign cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless object_validator.valid?(@object) + return false if @campaign.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code && + object == o.object && + campaign == o.campaign && + gift == o.gift && + loyalty_card == o.loyalty_card && + discount == o.discount && + is_referral_code == o.is_referral_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [code, object, campaign, gift, loyalty_card, discount, is_referral_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_delete_response_body.rb b/lib/VoucherifySdk/models/loyalties_delete_response_body.rb new file mode 100644 index 00000000..669919bb --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_delete_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **DELETE** `/loyalties/{campaignId}`. + class LoyaltiesDeleteResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesDeleteResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesDeleteResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_earning_rules_disable_response_body.rb b/lib/VoucherifySdk/models/loyalties_earning_rules_disable_response_body.rb new file mode 100644 index 00000000..fc3b882f --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_earning_rules_disable_response_body.rb @@ -0,0 +1,462 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/loyalties/{campaignId}/earning-rules/{earningRuleId}/disable` + class LoyaltiesEarningRulesDisableResponseBody + # Assigned by the Voucherify API, identifies the earning rule object. + attr_accessor :id + + # Timestamp representing the date and time when the earning rule was created in ISO 8601 format. + attr_accessor :created_at + + attr_accessor :loyalty + + attr_accessor :event + + attr_accessor :custom_event + + attr_accessor :segment + + attr_accessor :source + + # The type of object represented by JSON. Default is earning_rule. + attr_accessor :object + + # For internal use by Voucherify. + attr_accessor :automation_id + + # Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. + attr_accessor :start_date + + # Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. + attr_accessor :updated_at + + # A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. + attr_accessor :active + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'loyalty' => :'loyalty', + :'event' => :'event', + :'custom_event' => :'custom_event', + :'segment' => :'segment', + :'source' => :'source', + :'object' => :'object', + :'automation_id' => :'automation_id', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'metadata' => :'metadata', + :'updated_at' => :'updated_at', + :'active' => :'active' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'loyalty' => :'EarningRuleBaseLoyalty', + :'event' => :'EarningRuleEvent', + :'custom_event' => :'EarningRuleBaseCustomEvent', + :'segment' => :'EarningRuleBaseSegment', + :'source' => :'EarningRuleBaseSource', + :'object' => :'String', + :'automation_id' => :'String', + :'start_date' => :'String', + :'expiration_date' => :'String', + :'validity_timeframe' => :'EarningRuleBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'metadata' => :'Object', + :'updated_at' => :'Time', + :'active' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EarningRuleBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesEarningRulesDisableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesEarningRulesDisableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'event') + self.event = attributes[:'event'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'earning_rule' + end + + if attributes.key?(:'automation_id') + self.automation_id = attributes[:'automation_id'] + else + self.automation_id = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + else + self.active = false + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + if @source.nil? + invalid_properties.push('invalid value for "source", source cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @automation_id.nil? + invalid_properties.push('invalid value for "automation_id", automation_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @active.nil? + invalid_properties.push('invalid value for "active", active cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @created_at.nil? + return false if @loyalty.nil? + return false if @source.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["earning_rule"]) + return false unless object_validator.valid?(@object) + return false if @automation_id.nil? + return false if @metadata.nil? + return false if @active.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["earning_rule"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + loyalty == o.loyalty && + event == o.event && + custom_event == o.custom_event && + segment == o.segment && + source == o.source && + object == o.object && + automation_id == o.automation_id && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + metadata == o.metadata && + updated_at == o.updated_at && + active == o.active + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, loyalty, event, custom_event, segment, source, object, automation_id, start_date, expiration_date, validity_timeframe, validity_day_of_week, metadata, updated_at, active].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_earning_rules_enable_response_body.rb b/lib/VoucherifySdk/models/loyalties_earning_rules_enable_response_body.rb new file mode 100644 index 00000000..5639703a --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_earning_rules_enable_response_body.rb @@ -0,0 +1,462 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/loyalties/{campaignId}/earning-rules/{earningRuleId}/enable` + class LoyaltiesEarningRulesEnableResponseBody + # Assigned by the Voucherify API, identifies the earning rule object. + attr_accessor :id + + # Timestamp representing the date and time when the earning rule was created in ISO 8601 format. + attr_accessor :created_at + + attr_accessor :loyalty + + attr_accessor :event + + attr_accessor :custom_event + + attr_accessor :segment + + attr_accessor :source + + # The type of object represented by JSON. Default is earning_rule. + attr_accessor :object + + # For internal use by Voucherify. + attr_accessor :automation_id + + # Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. + attr_accessor :start_date + + # Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. + attr_accessor :updated_at + + # A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. + attr_accessor :active + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'loyalty' => :'loyalty', + :'event' => :'event', + :'custom_event' => :'custom_event', + :'segment' => :'segment', + :'source' => :'source', + :'object' => :'object', + :'automation_id' => :'automation_id', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'metadata' => :'metadata', + :'updated_at' => :'updated_at', + :'active' => :'active' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'loyalty' => :'EarningRuleBaseLoyalty', + :'event' => :'EarningRuleEvent', + :'custom_event' => :'EarningRuleBaseCustomEvent', + :'segment' => :'EarningRuleBaseSegment', + :'source' => :'EarningRuleBaseSource', + :'object' => :'String', + :'automation_id' => :'String', + :'start_date' => :'String', + :'expiration_date' => :'String', + :'validity_timeframe' => :'EarningRuleBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'metadata' => :'Object', + :'updated_at' => :'Time', + :'active' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EarningRuleBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesEarningRulesEnableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesEarningRulesEnableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'event') + self.event = attributes[:'event'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'earning_rule' + end + + if attributes.key?(:'automation_id') + self.automation_id = attributes[:'automation_id'] + else + self.automation_id = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + else + self.active = true + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + if @source.nil? + invalid_properties.push('invalid value for "source", source cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @automation_id.nil? + invalid_properties.push('invalid value for "automation_id", automation_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @active.nil? + invalid_properties.push('invalid value for "active", active cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @created_at.nil? + return false if @loyalty.nil? + return false if @source.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["earning_rule"]) + return false unless object_validator.valid?(@object) + return false if @automation_id.nil? + return false if @metadata.nil? + return false if @active.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["earning_rule"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + loyalty == o.loyalty && + event == o.event && + custom_event == o.custom_event && + segment == o.segment && + source == o.source && + object == o.object && + automation_id == o.automation_id && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + metadata == o.metadata && + updated_at == o.updated_at && + active == o.active + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, loyalty, event, custom_event, segment, source, object, automation_id, start_date, expiration_date, validity_timeframe, validity_day_of_week, metadata, updated_at, active].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_earning_rules_get_response_body.rb b/lib/VoucherifySdk/models/loyalties_earning_rules_get_response_body.rb new file mode 100644 index 00000000..8eed8842 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_earning_rules_get_response_body.rb @@ -0,0 +1,475 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/earning-rules/{earningRuleId}`. + class LoyaltiesEarningRulesGetResponseBody + # Assigned by the Voucherify API, identifies the earning rule object. + attr_accessor :id + + # Timestamp representing the date and time when the earning rule was created in ISO 8601 format. + attr_accessor :created_at + + attr_accessor :loyalty + + attr_accessor :event + + attr_accessor :custom_event + + attr_accessor :segment + + attr_accessor :source + + # The type of object represented by JSON. Default is earning_rule. + attr_accessor :object + + # For internal use by Voucherify. + attr_accessor :automation_id + + # Start date defines when the earning rule starts to be active. Activation timestamp in ISO 8601 format. Earning rule is inactive before this date. If you don't define the start date for an earning rule, it'll inherit the campaign start date by default. + attr_accessor :start_date + + # Expiration date defines when the earning rule expires. Expiration timestamp in ISO 8601 format. Earning rule is inactive after this date.If you don't define the expiration date for an earning rule, it'll inherit the campaign expiration date by default. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the earning rule is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format. + attr_accessor :metadata + + # A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. + attr_accessor :validation_rule_id + + # Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format. + attr_accessor :updated_at + + # A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. - `true` indicates an active earning rule - `false` indicates an inactive earning rule + attr_accessor :active + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'loyalty' => :'loyalty', + :'event' => :'event', + :'custom_event' => :'custom_event', + :'segment' => :'segment', + :'source' => :'source', + :'object' => :'object', + :'automation_id' => :'automation_id', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'metadata' => :'metadata', + :'validation_rule_id' => :'validation_rule_id', + :'updated_at' => :'updated_at', + :'active' => :'active' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'loyalty' => :'EarningRuleBaseLoyalty', + :'event' => :'EarningRuleEvent', + :'custom_event' => :'EarningRuleBaseCustomEvent', + :'segment' => :'EarningRuleBaseSegment', + :'source' => :'EarningRuleBaseSource', + :'object' => :'String', + :'automation_id' => :'String', + :'start_date' => :'String', + :'expiration_date' => :'String', + :'validity_timeframe' => :'EarningRuleBaseValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'metadata' => :'Object', + :'validation_rule_id' => :'String', + :'updated_at' => :'Time', + :'active' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'validation_rule_id', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'EarningRule' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesEarningRulesGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesEarningRulesGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'event') + self.event = attributes[:'event'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'earning_rule' + end + + if attributes.key?(:'automation_id') + self.automation_id = attributes[:'automation_id'] + else + self.automation_id = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'validation_rule_id') + self.validation_rule_id = attributes[:'validation_rule_id'] + else + self.validation_rule_id = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + else + self.active = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + if @source.nil? + invalid_properties.push('invalid value for "source", source cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @automation_id.nil? + invalid_properties.push('invalid value for "automation_id", automation_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @active.nil? + invalid_properties.push('invalid value for "active", active cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @created_at.nil? + return false if @loyalty.nil? + return false if @source.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["earning_rule"]) + return false unless object_validator.valid?(@object) + return false if @automation_id.nil? + return false if @metadata.nil? + return false if @active.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["earning_rule"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + loyalty == o.loyalty && + event == o.event && + custom_event == o.custom_event && + segment == o.segment && + source == o.source && + object == o.object && + automation_id == o.automation_id && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + metadata == o.metadata && + validation_rule_id == o.validation_rule_id && + updated_at == o.updated_at && + active == o.active + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, loyalty, event, custom_event, segment, source, object, automation_id, start_date, expiration_date, validity_timeframe, validity_day_of_week, metadata, validation_rule_id, updated_at, active].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_loyalty_tier_reward.rb b/lib/VoucherifySdk/models/loyalties_loyalty_tier_reward.rb new file mode 100644 index 00000000..fd9df993 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_loyalty_tier_reward.rb @@ -0,0 +1,289 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a loyalty tier reward. + class LoyaltiesLoyaltyTierReward + attr_accessor :reward + + attr_accessor :assignment + + # The type of object represented by JSON. This object stores information about the loyalty tier reward. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'reward' => :'reward', + :'assignment' => :'assignment', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'reward' => :'Reward', + :'assignment' => :'RewardAssignment', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesLoyaltyTierReward` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesLoyaltyTierReward`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + else + self.reward = nil + end + + if attributes.key?(:'assignment') + self.assignment = attributes[:'assignment'] + else + self.assignment = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'loyalty_tier_reward' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @reward.nil? + invalid_properties.push('invalid value for "reward", reward cannot be nil.') + end + + if @assignment.nil? + invalid_properties.push('invalid value for "assignment", assignment cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @reward.nil? + return false if @assignment.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["loyalty_tier_reward"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["loyalty_tier_reward"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + reward == o.reward && + assignment == o.assignment && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [reward, assignment, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_balance_update_request_body.rb b/lib/VoucherifySdk/models/loyalties_members_balance_update_request_body.rb new file mode 100644 index 00000000..fa329aed --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_balance_update_request_body.rb @@ -0,0 +1,284 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request Body schema for **post** `/loyalties/members/{memberId}/balance` and **POST** `/loyalties/{campaignId}/members/{memberId}/balance`. + class LoyaltiesMembersBalanceUpdateRequestBody + # Incremental balance to be added to/subtracted from the loyalty card. - To add points: 100 - To subtract points, add a minus: -100 + attr_accessor :points + + attr_accessor :expiration_type + + # Set expiration date for added points, i.e. `YYYY-MM-DD`. This parameter is required only when expiration_type is set to `CUSTOM_DATE`. + attr_accessor :expiration_date + + # Reason for the transfer. + attr_accessor :reason + + # The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'expiration_type' => :'expiration_type', + :'expiration_date' => :'expiration_date', + :'reason' => :'reason', + :'source_id' => :'source_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'expiration_type' => :'PointsExpirationTypes', + :'expiration_date' => :'Time', + :'reason' => :'String', + :'source_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersBalanceUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersBalanceUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'expiration_type') + self.expiration_type = attributes[:'expiration_type'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + expiration_type == o.expiration_type && + expiration_date == o.expiration_date && + reason == o.reason && + source_id == o.source_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, expiration_type, expiration_date, reason, source_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_balance_update_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_balance_update_response_body.rb new file mode 100644 index 00000000..4d3a8c77 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_balance_update_response_body.rb @@ -0,0 +1,399 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response schema for **POST** `/loyalties/members/{memberId}/balance` and for **POST** `/loyalties/{campaignId}/members/{memberId}/balance`. + class LoyaltiesMembersBalanceUpdateResponseBody + # The incremental points removed or added to the current balance on the loyalty card. + attr_accessor :points + + # The total of points accrued over the lifetime of the loyalty card. + attr_accessor :total + + # The balance after adding/removing points. + attr_accessor :balance + + # The type of voucher being modified. + attr_accessor :type + + # The type of object represented by JSON. Default is balance. + attr_accessor :object + + attr_accessor :related_object + + attr_accessor :operation_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'total' => :'total', + :'balance' => :'balance', + :'type' => :'type', + :'object' => :'object', + :'related_object' => :'related_object', + :'operation_type' => :'operation_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'total' => :'Integer', + :'balance' => :'Integer', + :'type' => :'String', + :'object' => :'String', + :'related_object' => :'LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject', + :'operation_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + else + self.balance = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'balance' + end + + if attributes.key?(:'related_object') + self.related_object = attributes[:'related_object'] + else + self.related_object = nil + end + + if attributes.key?(:'operation_type') + self.operation_type = attributes[:'operation_type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @balance.nil? + invalid_properties.push('invalid value for "balance", balance cannot be nil.') + end + + if @balance < 0 + invalid_properties.push('invalid value for "balance", must be greater than or equal to 0.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + pattern = Regexp.new(/balance/) + if @object !~ pattern + invalid_properties.push("invalid value for \"object\", must conform to the pattern #{pattern}.") + end + + if @related_object.nil? + invalid_properties.push('invalid value for "related_object", related_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @points.nil? + return false if @total.nil? + return false if @balance.nil? + return false if @balance < 0 + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["loyalty_card", "gift_voucher"]) + return false unless type_validator.valid?(@type) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["balance"]) + return false unless object_validator.valid?(@object) + return false if @object !~ Regexp.new(/balance/) + return false if @related_object.nil? + operation_type_validator = EnumAttributeValidator.new('String', ["MANUAL", "AUTOMATIC"]) + return false unless operation_type_validator.valid?(@operation_type) + true + end + + # Custom attribute writer method with validation + # @param [Object] balance Value to be assigned + def balance=(balance) + if balance.nil? + fail ArgumentError, 'balance cannot be nil' + end + + if balance < 0 + fail ArgumentError, 'invalid value for "balance", must be greater than or equal to 0.' + end + + @balance = balance + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["loyalty_card", "gift_voucher"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["balance"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] operation_type Object to be assigned + def operation_type=(operation_type) + validator = EnumAttributeValidator.new('String', ["MANUAL", "AUTOMATIC"]) + unless validator.valid?(operation_type) + fail ArgumentError, "invalid value for \"operation_type\", must be one of #{validator.allowable_values}." + end + @operation_type = operation_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + total == o.total && + balance == o.balance && + type == o.type && + object == o.object && + related_object == o.related_object && + operation_type == o.operation_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, total, balance, type, object, related_object, operation_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_balance_update_response_body_related_object.rb b/lib/VoucherifySdk/models/loyalties_members_balance_update_response_body_related_object.rb new file mode 100644 index 00000000..eceed339 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_balance_update_response_body_related_object.rb @@ -0,0 +1,274 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the object that is being modified with the values that are returned in the balance object. + class LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject + # The object being modified. + attr_accessor :type + + # Identifies the loyalty card that is being modified, this is the ID that was assigned by the Voucherify API. + attr_accessor :id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersBalanceUpdateResponseBodyRelatedObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'voucher' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless type_validator.valid?(@type) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body.rb new file mode 100644 index 00000000..8bec69c0 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body.rb @@ -0,0 +1,334 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/members/{memberId}/points-expiration`. + class LoyaltiesMembersPointsExpirationListResponseBody + # The type of object represented by JSON. This object stores information about loyalty points expiration buckets in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of loyalty points expiration bucket objects. + attr_accessor :data_ref + + # Contains array of loyalty points expiration buckets. + attr_accessor :data + + # Total number of point expiration buckets. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + pattern = Regexp.new(/list/) + if @object !~ pattern + invalid_properties.push("invalid value for \"object\", must conform to the pattern #{pattern}.") + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + pattern = Regexp.new(/data/) + if @data_ref !~ pattern + invalid_properties.push("invalid value for \"data_ref\", must conform to the pattern #{pattern}.") + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @object !~ Regexp.new(/list/) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data_ref !~ Regexp.new(/data/) + return false if @data.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item.rb b/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item.rb new file mode 100644 index 00000000..7a710538 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item.rb @@ -0,0 +1,390 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltiesMembersPointsExpirationListResponseBodyDataItem + # Unique loyalty points bucket ID. + attr_accessor :id + + # Unique parent loyalty card ID. + attr_accessor :voucher_id + + # Unique parent campaign ID. + attr_accessor :campaign_id + + attr_accessor :bucket + + # Timestamp representing the date and time when the loyalty points bucket object was created in ISO 8601 format. + attr_accessor :created_at + + # Loyalty points bucket point status. + attr_accessor :status + + # Date when the number of points defined in the bucket object are due to expire. + attr_accessor :expires_at + + # Timestamp representing the date and time when the loyalty points bucket object was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the loyalty points bucket. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'voucher_id' => :'voucher_id', + :'campaign_id' => :'campaign_id', + :'bucket' => :'bucket', + :'created_at' => :'created_at', + :'status' => :'status', + :'expires_at' => :'expires_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'voucher_id' => :'String', + :'campaign_id' => :'String', + :'bucket' => :'LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket', + :'created_at' => :'Time', + :'status' => :'String', + :'expires_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'voucher_id') + self.voucher_id = attributes[:'voucher_id'] + else + self.voucher_id = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'bucket') + self.bucket = attributes[:'bucket'] + else + self.bucket = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'expires_at') + self.expires_at = attributes[:'expires_at'] + else + self.expires_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'loyalty_points_bucket' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @voucher_id.nil? + invalid_properties.push('invalid value for "voucher_id", voucher_id cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @bucket.nil? + invalid_properties.push('invalid value for "bucket", bucket cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @expires_at.nil? + invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + pattern = Regexp.new(/loyalty_points_bucket/) + if @object !~ pattern + invalid_properties.push("invalid value for \"object\", must conform to the pattern #{pattern}.") + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @voucher_id.nil? + return false if @campaign_id.nil? + return false if @bucket.nil? + return false if @created_at.nil? + return false if @status.nil? + return false if @expires_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["loyalty_points_bucket"]) + return false unless object_validator.valid?(@object) + return false if @object !~ Regexp.new(/loyalty_points_bucket/) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["loyalty_points_bucket"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + voucher_id == o.voucher_id && + campaign_id == o.campaign_id && + bucket == o.bucket && + created_at == o.created_at && + status == o.status && + expires_at == o.expires_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, voucher_id, campaign_id, bucket, created_at, status, expires_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item_bucket.rb b/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item_bucket.rb new file mode 100644 index 00000000..8227c5b8 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_points_expiration_list_response_body_data_item_bucket.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the number of points stored in the given loyalty points bucket. + class LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket + # Total number of points in the loyalty points bucket. + attr_accessor :total_points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total_points' => :'total_points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total_points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersPointsExpirationListResponseBodyDataItemBucket`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total_points') + self.total_points = attributes[:'total_points'] + else + self.total_points = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @total_points.nil? + invalid_properties.push('invalid value for "total_points", total_points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @total_points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_points == o.total_points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total_points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_request_body.rb b/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_request_body.rb new file mode 100644 index 00000000..c3b49930 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_request_body.rb @@ -0,0 +1,234 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/loyalties/{campaignId}/members/{memberId}/redemption` and for **POST** and `/loyalties/members/{memberId}/redemption`. + class LoyaltiesMembersRedemptionRedeemRequestBody + attr_accessor :reward + + attr_accessor :order + + # A set of key/value pairs that you can send in the request body to check against vouchers requiring **redemption** metadata validation rules to be satisfied. The validation runs against rules that are defined through the [Create Validation Rules](ref:create-validation-rules) endpoint or via the Dashboard; in the _Advanced Rule Builder_ → _Advanced_ → _Redemption metadata satisfy_ or _Basic Builder_ → _Attributes match_ → _REDEMPTION METADATA_. [Read more](https://support.voucherify.io/article/148-how-to-build-a-rule). + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'reward' => :'reward', + :'order' => :'order', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'reward' => :'LoyaltiesMembersRedemptionRedeemRequestBodyReward', + :'order' => :'Order', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + reward == o.reward && + order == o.order && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [reward, order, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_request_body_reward.rb b/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_request_body_reward.rb new file mode 100644 index 00000000..5ea4e138 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_request_body_reward.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the reward that the customer wants to redeem and the number of points the customer is choosing to use for the reward if the reward is a pay with points reward. + class LoyaltiesMembersRedemptionRedeemRequestBodyReward + # Unique reward ID assigned by Voucherify. The reward must be assigned to the campaign in order for the user to be able to use the reward. + attr_accessor :id + + # The number of loyalty points that the user wants to spend in order to fulfill the order. The number of points cannot be higher than the current balance on the loyalty card. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBodyReward` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersRedemptionRedeemRequestBodyReward`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_response_body.rb new file mode 100644 index 00000000..1e99441e --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_redemption_redeem_response_body.rb @@ -0,0 +1,585 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/loyalties/{campaignId}/members/{memberId}/redemption` and for **POST** `/loyalties/members/{memberId}/redemption`. + class LoyaltiesMembersRedemptionRedeemResponseBody + # Unique redemption ID. + attr_accessor :id + + # The type of object represented by the JSON + attr_accessor :object + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Unique customer ID of the redeeming customer. + attr_accessor :customer_id + + # Hashed customer source ID. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the redemption. + attr_accessor :metadata + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Unique redemption ID of the parent redemption. + attr_accessor :redemption + + # Redemption result. + attr_accessor :result + + # Redemption status. + attr_accessor :status + + attr_accessor :related_redemptions + + # If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. + attr_accessor :failure_code + + # If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. + attr_accessor :failure_message + + attr_accessor :order + + attr_accessor :channel + + attr_accessor :customer + + # Defines the related object. + attr_accessor :related_object_type + + # Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. + attr_accessor :related_object_id + + attr_accessor :voucher + + attr_accessor :promotion_tier + + attr_accessor :reward + + attr_accessor :gift + + attr_accessor :loyalty_card + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'date' => :'date', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'amount' => :'amount', + :'redemption' => :'redemption', + :'result' => :'result', + :'status' => :'status', + :'related_redemptions' => :'related_redemptions', + :'failure_code' => :'failure_code', + :'failure_message' => :'failure_message', + :'order' => :'order', + :'channel' => :'channel', + :'customer' => :'customer', + :'related_object_type' => :'related_object_type', + :'related_object_id' => :'related_object_id', + :'voucher' => :'voucher', + :'promotion_tier' => :'promotion_tier', + :'reward' => :'reward', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'date' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'amount' => :'Integer', + :'redemption' => :'String', + :'result' => :'String', + :'status' => :'String', + :'related_redemptions' => :'RedemptionRelatedRedemptions', + :'failure_code' => :'String', + :'failure_message' => :'String', + :'order' => :'OrderCalculatedNoCustomerData', + :'channel' => :'RedemptionChannel', + :'customer' => :'SimpleCustomer', + :'related_object_type' => :'String', + :'related_object_id' => :'String', + :'voucher' => :'Voucher', + :'promotion_tier' => :'PromotionTier', + :'reward' => :'RedemptionRewardResult', + :'gift' => :'RedemptionGift', + :'loyalty_card' => :'RedemptionLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer_id', + :'tracking_id', + :'metadata', + :'redemption', + :'order', + :'customer', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Redemption' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersRedemptionRedeemResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersRedemptionRedeemResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'redemption' + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + else + self.date = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + else + self.tracking_id = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + else + self.redemption = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'related_redemptions') + self.related_redemptions = attributes[:'related_redemptions'] + end + + if attributes.key?(:'failure_code') + self.failure_code = attributes[:'failure_code'] + end + + if attributes.key?(:'failure_message') + self.failure_message = attributes[:'failure_message'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + else + self.order = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + else + self.reward = nil + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @date.nil? + invalid_properties.push('invalid value for "date", date cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @reward.nil? + invalid_properties.push('invalid value for "reward", reward cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["redemption"]) + return false unless object_validator.valid?(@object) + return false if @date.nil? + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + return false unless result_validator.valid?(@result) + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED", "ROLLED_BACK"]) + return false unless status_validator.valid?(@status) + return false if @channel.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + return false unless related_object_type_validator.valid?(@related_object_type) + return false if @related_object_id.nil? + return false if @reward.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["redemption"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED", "ROLLED_BACK"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + date == o.date && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + amount == o.amount && + redemption == o.redemption && + result == o.result && + status == o.status && + related_redemptions == o.related_redemptions && + failure_code == o.failure_code && + failure_message == o.failure_message && + order == o.order && + channel == o.channel && + customer == o.customer && + related_object_type == o.related_object_type && + related_object_id == o.related_object_id && + voucher == o.voucher && + promotion_tier == o.promotion_tier && + reward == o.reward && + gift == o.gift && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, date, customer_id, tracking_id, metadata, amount, redemption, result, status, related_redemptions, failure_code, failure_message, order, channel, customer, related_object_type, related_object_id, voucher, promotion_tier, reward, gift, loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_rewards_list_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_rewards_list_response_body.rb new file mode 100644 index 00000000..f31c6b0d --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_rewards_list_response_body.rb @@ -0,0 +1,341 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/members/{memberId}/rewards` + class LoyaltiesMembersRewardsListResponseBody + # The type of object represented by JSON. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of loyalty reward objects. + attr_accessor :data_ref + + # Contains array of loyalty reward objects. + attr_accessor :data + + # Total number of loyalty reward objects. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersRewardsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersRewardsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @total < 0 + invalid_properties.push('invalid value for "total", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + return false if @total < 0 + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Custom attribute writer method with validation + # @param [Object] total Value to be assigned + def total=(total) + if total.nil? + fail ArgumentError, 'total cannot be nil' + end + + if total < 0 + fail ArgumentError, 'invalid value for "total", must be greater than or equal to 0.' + end + + @total = total + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_rewards_list_response_body_data_item.rb b/lib/VoucherifySdk/models/loyalties_members_rewards_list_response_body_data_item.rb new file mode 100644 index 00000000..73d868b4 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_rewards_list_response_body_data_item.rb @@ -0,0 +1,269 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltiesMembersRewardsListResponseBodyDataItem + attr_accessor :reward + + attr_accessor :assignment + + # The type of object represented by JSON. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'reward' => :'reward', + :'assignment' => :'assignment', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'reward' => :'Reward', + :'assignment' => :'RewardAssignment', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersRewardsListResponseBodyDataItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersRewardsListResponseBodyDataItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'assignment') + self.assignment = attributes[:'assignment'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'loyalty_reward' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["loyalty_reward"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["loyalty_reward"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + reward == o.reward && + assignment == o.assignment && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [reward, assignment, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_tiers_list_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_tiers_list_response_body.rb new file mode 100644 index 00000000..d1d74b84 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_tiers_list_response_body.rb @@ -0,0 +1,321 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/members/{memberId}/tiers`. + class LoyaltiesMembersTiersListResponseBody + # The type of object represented by JSON. This object stores information about loyalty tiers in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of loyalty tier objects. + attr_accessor :data_ref + + attr_accessor :data + + # Total number of loyalty tier objects. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTiersListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTiersListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_request_body.rb b/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_request_body.rb new file mode 100644 index 00000000..d75192e7 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_request_body.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/loyalties/members/{memberId}/transactions/export` and for **POST** `/loyalties/{campaignId}/members/{memberId}/transactions/export`. + class LoyaltiesMembersTransactionsExportCreateRequestBody + attr_accessor :parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'parameters' => :'LoyaltiesMembersTransactionsExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_request_body_parameters.rb b/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_request_body_parameters.rb new file mode 100644 index 00000000..f2bcea84 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_request_body_parameters.rb @@ -0,0 +1,258 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with an order along with the sorting order of the returned data. + class LoyaltiesMembersTransactionsExportCreateRequestBodyParameters + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. + attr_accessor :fields + + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'ExportVoucherTransactionsOrder', + :'fields' => :'Array', + :'filters' => :'ExportVoucherTransactionsFilters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBodyParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransactionsExportCreateRequestBodyParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_response_body.rb new file mode 100644 index 00000000..e52c658f --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transactions_export_create_response_body.rb @@ -0,0 +1,405 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/loyalties/members/{memberId}/transactions/export` and for **POST** `/loyalties/{campaignId}/members/{memberId}/transactions/export`. + class LoyaltiesMembersTransactionsExportCreateResponseBody + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'LoyaltiesMembersTransactionsExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportVoucherTransactionsScheduled' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransactionsExportCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransactionsExportCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher_transactions' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transactions_list_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_transactions_list_response_body.rb new file mode 100644 index 00000000..d69d19a2 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transactions_list_response_body.rb @@ -0,0 +1,334 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/members/{memberId}/transactions` and `/loyalties/members/{memberId}/transactions`. + class LoyaltiesMembersTransactionsListResponseBody + # The type of object represented by JSON. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of transaction objects. + attr_accessor :data_ref + + # A dictionary that contains an array of transactions. Each entry in the array is a separate transaction object. + attr_accessor :data + + # As query results are always limited (by the limit parameter), the has_more flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. + attr_accessor :has_more + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'has_more' => :'has_more' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'has_more' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransactionsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransactionsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + else + self.has_more = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + pattern = Regexp.new(/list/) + if @object !~ pattern + invalid_properties.push("invalid value for \"object\", must conform to the pattern #{pattern}.") + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + pattern = Regexp.new(/data/) + if @data_ref !~ pattern + invalid_properties.push("invalid value for \"data_ref\", must conform to the pattern #{pattern}.") + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @has_more.nil? + invalid_properties.push('invalid value for "has_more", has_more cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @object !~ Regexp.new(/list/) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data_ref !~ Regexp.new(/data/) + return false if @data.nil? + return false if @has_more.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + has_more == o.has_more + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, has_more].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body.rb new file mode 100644 index 00000000..e6ffaac0 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body.rb @@ -0,0 +1,544 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/loyalties/{campaignId}/members/{memberId}/transfers`. + class LoyaltiesMembersTransfersCreateResponseBody + # Assigned by the Voucherify API, identifies the voucher. + attr_accessor :id + + # A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. + attr_accessor :code + + # A unique campaign name, identifies the voucher's parent campaign. + attr_accessor :campaign + + # Assigned by the Voucherify API, identifies the voucher's parent campaign. + attr_accessor :campaign_id + + # Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. + attr_accessor :category + + # Unique category ID assigned by Voucherify. + attr_accessor :category_id + + attr_accessor :categories + + # Defines the type of the voucher. + attr_accessor :type + + attr_accessor :loyalty_card + + # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is inactive before this date. + attr_accessor :start_date + + # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is inactive after this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + attr_accessor :publish + + attr_accessor :redemption + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the start_date and expiration_date. - `true` indicates an active voucher - `false` indicates an inactive voucher + attr_accessor :active + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :assets + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Unique customer ID of voucher owner. + attr_accessor :holder_id + + # Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :created_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'category' => :'category', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'type' => :'type', + :'loyalty_card' => :'loyalty_card', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'publish' => :'publish', + :'redemption' => :'redemption', + :'active' => :'active', + :'additional_info' => :'additional_info', + :'metadata' => :'metadata', + :'assets' => :'assets', + :'is_referral_code' => :'is_referral_code', + :'holder_id' => :'holder_id', + :'updated_at' => :'updated_at', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'campaign' => :'String', + :'campaign_id' => :'String', + :'category' => :'String', + :'category_id' => :'String', + :'categories' => :'Array', + :'type' => :'String', + :'loyalty_card' => :'LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'publish' => :'LoyaltiesMembersTransfersCreateResponseBodyPublish', + :'redemption' => :'LoyaltiesMembersTransfersCreateResponseBodyRedemption', + :'active' => :'String', + :'additional_info' => :'String', + :'metadata' => :'Object', + :'assets' => :'LoyaltiesMembersTransfersCreateResponseBodyAssets', + :'is_referral_code' => :'Boolean', + :'holder_id' => :'String', + :'updated_at' => :'Time', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category', + :'category_id', + :'start_date', + :'expiration_date', + :'validity_timeframe', + :'validity_day_of_week', + :'additional_info', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + else + self.category = nil + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'LOYALTY_CARD' + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + else + self.loyalty_card = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + else + self.start_date = nil + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + else + self.expiration_date = nil + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + else + self.validity_timeframe = nil + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + else + self.validity_day_of_week = nil + end + + if attributes.key?(:'publish') + self.publish = attributes[:'publish'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + else + self.active = nil + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + else + self.additional_info = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + else + self.is_referral_code = nil + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @loyalty_card.nil? + invalid_properties.push('invalid value for "loyalty_card", loyalty_card cannot be nil.') + end + + if @active.nil? + invalid_properties.push('invalid value for "active", active cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @is_referral_code.nil? + invalid_properties.push('invalid value for "is_referral_code", is_referral_code cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @code.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + return false if @loyalty_card.nil? + return false if @active.nil? + return false if @metadata.nil? + return false if @is_referral_code.nil? + return false if @created_at.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + campaign == o.campaign && + campaign_id == o.campaign_id && + category == o.category && + category_id == o.category_id && + categories == o.categories && + type == o.type && + loyalty_card == o.loyalty_card && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + publish == o.publish && + redemption == o.redemption && + active == o.active && + additional_info == o.additional_info && + metadata == o.metadata && + assets == o.assets && + is_referral_code == o.is_referral_code && + holder_id == o.holder_id && + updated_at == o.updated_at && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, campaign, campaign_id, category, category_id, categories, type, loyalty_card, start_date, expiration_date, validity_timeframe, validity_day_of_week, publish, redemption, active, additional_info, metadata, assets, is_referral_code, holder_id, updated_at, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets.rb new file mode 100644 index 00000000..27f53cf4 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets.rb @@ -0,0 +1,224 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores links to images of QR and barcode that correspond to an encrypted voucher code. + class LoyaltiesMembersTransfersCreateResponseBodyAssets + attr_accessor :qr + + attr_accessor :barcode + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'qr' => :'qr', + :'barcode' => :'barcode' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'qr' => :'LoyaltiesMembersTransfersCreateResponseBodyAssetsQr', + :'barcode' => :'LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssets` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssets`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'qr') + self.qr = attributes[:'qr'] + end + + if attributes.key?(:'barcode') + self.barcode = attributes[:'barcode'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + qr == o.qr && + barcode == o.barcode + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [qr, barcode].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_barcode.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_barcode.rb new file mode 100644 index 00000000..499cd689 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_barcode.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores barcode representation of encrypted code. + class LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode + # Encrypted voucher code ID. + attr_accessor :id + + # URL to barcode *Optional:* Attach query parameters to base URL to customize the image of the encrypted voucher code. - `size`: integer value from `1` to `100` - `format`: string, either `png` (default) or `svg` + attr_accessor :url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_qr.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_qr.rb new file mode 100644 index 00000000..e5384b14 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_assets_qr.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores Quick Response (QR) representation of encrypted code. + class LoyaltiesMembersTransfersCreateResponseBodyAssetsQr + # Encrypted voucher code ID. + attr_accessor :id + + # URL to QR code *Optional:* Attach query parameters to base URL to customize the image of the encrypted voucher code. - `size`: integer value from `1` to `100` - `format`: string, either `png` (default) or `svg` + attr_accessor :url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsQr` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyAssetsQr`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_loyalty_card.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_loyalty_card.rb new file mode 100644 index 00000000..ed622798 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_loyalty_card.rb @@ -0,0 +1,260 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Object representing loyalty card parameters. Child attributes are present only if type is LOYALTY_CARD. + class LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard + # Total points incurred over lifespan of loyalty card. + attr_accessor :points + + # Points available for reward redemption. + attr_accessor :balance + + # The next closest date when the next set of points are due to expire. + attr_accessor :next_expiration_date + + # The amount of points that are set to expire next. + attr_accessor :next_expiration_points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'balance' => :'balance', + :'next_expiration_date' => :'next_expiration_date', + :'next_expiration_points' => :'next_expiration_points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'balance' => :'Integer', + :'next_expiration_date' => :'String', + :'next_expiration_points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + else + self.balance = nil + end + + if attributes.key?(:'next_expiration_date') + self.next_expiration_date = attributes[:'next_expiration_date'] + end + + if attributes.key?(:'next_expiration_points') + self.next_expiration_points = attributes[:'next_expiration_points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @balance.nil? + invalid_properties.push('invalid value for "balance", balance cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @points.nil? + return false if @balance.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + balance == o.balance && + next_expiration_date == o.next_expiration_date && + next_expiration_points == o.next_expiration_points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, balance, next_expiration_date, next_expiration_points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_publish.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_publish.rb new file mode 100644 index 00000000..32ce8286 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_publish.rb @@ -0,0 +1,288 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This object stores a summary of publish events: an events counter and an endpoint which can be called to return details of each event. A publication is required for loyalty cards and referral codes. This object gets updated whenever a voucher has been published. Publication means assigning a code to a particular customer. Typically, a publication is made by distributing your codes to your customers, e.g. through Export to MailChimp or publish voucher API method. + class LoyaltiesMembersTransfersCreateResponseBodyPublish + # The type of object represented is by default list. To get this list, you need to make a call to the endpoint returned in the url attribute. + attr_accessor :object + + # Publication events counter. + attr_accessor :count + + attr_accessor :entries + + # The endpoint where this list of publications can be accessed using a GET method. /v1/vouchers/{voucher_code}/publications + attr_accessor :url + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'count' => :'count', + :'entries' => :'entries', + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'count' => :'Integer', + :'entries' => :'Array', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyPublish` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyPublish`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'count') + self.count = attributes[:'count'] + end + + if attributes.key?(:'entries') + if (value = attributes[:'entries']).is_a?(Array) + self.entries = value + end + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + count == o.count && + entries == o.entries && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, count, entries, url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_redemption.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_redemption.rb new file mode 100644 index 00000000..eae2736b --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_redemption.rb @@ -0,0 +1,306 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores a summary of redemptions that have been applied to the voucher. + class LoyaltiesMembersTransfersCreateResponseBodyRedemption + # How many times a voucher can be redeemed. A null value means unlimited. + attr_accessor :quantity + + # Total loyalty points redeemed. + attr_accessor :redeemed_points + + # How many times a voucher has already been redeemed. + attr_accessor :redeemed_quantity + + attr_accessor :redemption_entries + + # The type of object represented is by default list. To get this list, you need to make a call to the endpoint returned in the url attribute. + attr_accessor :object + + # The endpoint where this list of redemptions can be accessed using a GET method. /v1/vouchers/{voucher_code}/redemptions + attr_accessor :url + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'quantity' => :'quantity', + :'redeemed_points' => :'redeemed_points', + :'redeemed_quantity' => :'redeemed_quantity', + :'redemption_entries' => :'redemption_entries', + :'object' => :'object', + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'quantity' => :'Integer', + :'redeemed_points' => :'Integer', + :'redeemed_quantity' => :'Integer', + :'redemption_entries' => :'Array', + :'object' => :'String', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'quantity', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end + + if attributes.key?(:'redeemed_points') + self.redeemed_points = attributes[:'redeemed_points'] + end + + if attributes.key?(:'redeemed_quantity') + self.redeemed_quantity = attributes[:'redeemed_quantity'] + end + + if attributes.key?(:'redemption_entries') + if (value = attributes[:'redemption_entries']).is_a?(Array) + self.redemption_entries = value + end + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + quantity == o.quantity && + redeemed_points == o.redeemed_points && + redeemed_quantity == o.redeemed_quantity && + redemption_entries == o.redemption_entries && + object == o.object && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [quantity, redeemed_points, redeemed_quantity, redemption_entries, object, url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_validity_timeframe.rb b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_validity_timeframe.rb new file mode 100644 index 00000000..759111c2 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_members_transfers_create_response_body_validity_timeframe.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Set recurrent time periods when the voucher is valid. For example, valid for 1 hour every other day.start_date required when including the validity_timeframe. + class LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe + # Defines the amount of time the voucher will be active in ISO 8601 format. For example, a voucher with a duration of PT1H will be valid for a duration of one hour. + attr_accessor :interval + + # Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a voucher with an interval of P2D will be active every other day. + attr_accessor :duration + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'interval' => :'interval', + :'duration' => :'duration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'interval' => :'String', + :'duration' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesMembersTransfersCreateResponseBodyValidityTimeframe`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'interval') + self.interval = attributes[:'interval'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + interval == o.interval && + duration == o.duration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [interval, duration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_reward_assignments_get_response_body.rb b/lib/VoucherifySdk/models/loyalties_reward_assignments_get_response_body.rb new file mode 100644 index 00000000..7fa85317 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_reward_assignments_get_response_body.rb @@ -0,0 +1,383 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/reward-assignments/{assignmentId}`. + class LoyaltiesRewardAssignmentsGetResponseBody + # Unique reward assignment ID, assigned by Voucherify. + attr_accessor :id + + # Associated reward ID. + attr_accessor :reward_id + + # Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward assignment. + attr_accessor :object + + # Related object ID to which the reward was assigned. + attr_accessor :related_object_id + + # Related object type to which the reward was assigned. + attr_accessor :related_object_type + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'reward_id' => :'reward_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'reward_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'parameters' => :'RewardAssignmentParametersParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RewardAssignment' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesRewardAssignmentsGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesRewardAssignmentsGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward_id') + self.reward_id = attributes[:'reward_id'] + else + self.reward_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward_assignment' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'campaign' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @reward_id.nil? + invalid_properties.push('invalid value for "reward_id", reward_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @reward_id.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + return false unless object_validator.valid?(@object) + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + reward_id == o.reward_id && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, reward_id, created_at, updated_at, object, related_object_id, related_object_type, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_reward_assignments_reward_get_response_body.rb b/lib/VoucherifySdk/models/loyalties_reward_assignments_reward_get_response_body.rb new file mode 100644 index 00000000..224a170b --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_reward_assignments_reward_get_response_body.rb @@ -0,0 +1,418 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/reward-assignments/{assignmentId}/reward` + class LoyaltiesRewardAssignmentsRewardGetResponseBody + # Unique reward ID, assigned by Voucherify. + attr_accessor :id + + # Reward name. + attr_accessor :name + + # Configurable for **material rewards**. The number of units of the product that you want to share as reward. + attr_accessor :stock + + # Defines the number of already invoked (successful) reward redemptions. + attr_accessor :redeemed + + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the reward. A set of key/value pairs that you can attach to a reward object. It can be useful for storing additional information about the reward in a structured format. + attr_accessor :metadata + + # Reward type. + attr_accessor :type + + attr_accessor :parameters + + # Timestamp representing the date and time when the reward was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'stock' => :'stock', + :'redeemed' => :'redeemed', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'type' => :'type', + :'parameters' => :'parameters', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'stock' => :'Integer', + :'redeemed' => :'Integer', + :'attributes' => :'RewardAttributes', + :'metadata' => :'Object', + :'type' => :'String', + :'parameters' => :'RewardType', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'stock', + :'redeemed', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Reward' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesRewardAssignmentsRewardGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesRewardAssignmentsRewardGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'stock') + self.stock = attributes[:'stock'] + else + self.stock = nil + end + + if attributes.key?(:'redeemed') + self.redeemed = attributes[:'redeemed'] + else + self.redeemed = nil + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @metadata.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + return false unless type_validator.valid?(@type) + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + stock == o.stock && + redeemed == o.redeemed && + attributes == o.attributes && + metadata == o.metadata && + type == o.type && + parameters == o.parameters && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, stock, redeemed, attributes, metadata, type, parameters, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_rewards_get_response_body.rb b/lib/VoucherifySdk/models/loyalties_rewards_get_response_body.rb new file mode 100644 index 00000000..bc4770b4 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_rewards_get_response_body.rb @@ -0,0 +1,383 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/rewards/{assignmentId}` + class LoyaltiesRewardsGetResponseBody + # Unique reward assignment ID, assigned by Voucherify. + attr_accessor :id + + # Associated reward ID. + attr_accessor :reward_id + + # Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward assignment. + attr_accessor :object + + # Related object ID to which the reward was assigned. + attr_accessor :related_object_id + + # Related object type to which the reward was assigned. + attr_accessor :related_object_type + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'reward_id' => :'reward_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'reward_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'parameters' => :'RewardAssignmentParametersParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RewardAssignment' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesRewardsGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesRewardsGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward_id') + self.reward_id = attributes[:'reward_id'] + else + self.reward_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward_assignment' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'campaign' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @reward_id.nil? + invalid_properties.push('invalid value for "reward_id", reward_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @reward_id.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + return false unless object_validator.valid?(@object) + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + reward_id == o.reward_id && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, reward_id, created_at, updated_at, object, related_object_id, related_object_type, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_tiers_create_in_bulk_request_body_item.rb b/lib/VoucherifySdk/models/loyalties_tiers_create_in_bulk_request_body_item.rb new file mode 100644 index 00000000..de38df03 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_tiers_create_in_bulk_request_body_item.rb @@ -0,0 +1,279 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltiesTiersCreateInBulkRequestBodyItem + # Loyalty Tier name. + attr_accessor :name + + # Contains a list of earning rule IDs and their points mapping for the given earning rule. + attr_accessor :earning_rules + + # Contains a list of reward IDs and their points mapping for the given reward. + attr_accessor :rewards + + attr_accessor :points + + # The metadata object stores all custom attributes assigned to the loyalty tier. A set of key/value pairs that you can attach to a loyalty tier object. It can be useful for storing additional information about the loyalty tier in a structured format. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'earning_rules' => :'earning_rules', + :'rewards' => :'rewards', + :'points' => :'points', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'earning_rules' => :'Hash', + :'rewards' => :'Hash', + :'points' => :'LoyaltyTierBasePoints', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'LoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesTiersCreateInBulkRequestBodyItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesTiersCreateInBulkRequestBodyItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'earning_rules') + if (value = attributes[:'earning_rules']).is_a?(Hash) + self.earning_rules = value + end + end + + if attributes.key?(:'rewards') + if (value = attributes[:'rewards']).is_a?(Hash) + self.rewards = value + end + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + earning_rules == o.earning_rules && + rewards == o.rewards && + points == o.points && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, earning_rules, rewards, points, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_tiers_earning_rules_list_response_body.rb b/lib/VoucherifySdk/models/loyalties_tiers_earning_rules_list_response_body.rb new file mode 100644 index 00000000..3c5285bf --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_tiers_earning_rules_list_response_body.rb @@ -0,0 +1,322 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/tiers/{loyaltyTierId}/earning-rules`. + class LoyaltiesTiersEarningRulesListResponseBody + # The type of object represented by JSON. This object stores information about earning rules in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of earning rule objects. + attr_accessor :data_ref + + # Contains array of earning rule objects. + attr_accessor :data + + # Total number of earning rule objects. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesTiersEarningRulesListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesTiersEarningRulesListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_tiers_get_response_body.rb b/lib/VoucherifySdk/models/loyalties_tiers_get_response_body.rb new file mode 100644 index 00000000..7d0b4d89 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_tiers_get_response_body.rb @@ -0,0 +1,421 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/tiers/{loyaltyTierId}`. + class LoyaltiesTiersGetResponseBody + # Loyalty Tier name. + attr_accessor :name + + # Contains a list of earning rule IDs and their points mapping for the given earning rule. + attr_accessor :earning_rules + + # Contains a list of reward IDs and their points mapping for the given reward. + attr_accessor :rewards + + attr_accessor :points + + # Unique loyalty tier ID. + attr_accessor :id + + # Unique parent campaign ID. + attr_accessor :campaign_id + + # The metadata object stores all custom attributes assigned to the loyalty tier. A set of key/value pairs that you can attach to a loyalty tier object. It can be useful for storing additional information about the loyalty tier in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the loyalty tier was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the loyalty tier was updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :config + + attr_accessor :expiration + + # The type of object represented by JSON. This object stores information about the loyalty. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'earning_rules' => :'earning_rules', + :'rewards' => :'rewards', + :'points' => :'points', + :'id' => :'id', + :'campaign_id' => :'campaign_id', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'config' => :'config', + :'expiration' => :'expiration', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'earning_rules' => :'Hash', + :'rewards' => :'Hash', + :'points' => :'LoyaltyTierBasePoints', + :'id' => :'String', + :'campaign_id' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'config' => :'LoyaltyTierAllOfConfig', + :'expiration' => :'LoyaltyTierExpiration', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'metadata', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'LoyaltyTier' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesTiersGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesTiersGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'earning_rules') + if (value = attributes[:'earning_rules']).is_a?(Hash) + self.earning_rules = value + end + end + + if attributes.key?(:'rewards') + if (value = attributes[:'rewards']).is_a?(Hash) + self.rewards = value + end + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'config') + self.config = attributes[:'config'] + else + self.config = nil + end + + if attributes.key?(:'expiration') + self.expiration = attributes[:'expiration'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'loyalty_tier' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @config.nil? + invalid_properties.push('invalid value for "config", config cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @points.nil? + return false if @id.nil? + return false if @campaign_id.nil? + return false if @created_at.nil? + return false if @config.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["loyalty_tier"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["loyalty_tier"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + earning_rules == o.earning_rules && + rewards == o.rewards && + points == o.points && + id == o.id && + campaign_id == o.campaign_id && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + config == o.config && + expiration == o.expiration && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, earning_rules, rewards, points, id, campaign_id, metadata, created_at, updated_at, config, expiration, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_tiers_list_response_body.rb b/lib/VoucherifySdk/models/loyalties_tiers_list_response_body.rb new file mode 100644 index 00000000..e91d44cf --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_tiers_list_response_body.rb @@ -0,0 +1,322 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/tiers`. + class LoyaltiesTiersListResponseBody + # The type of object represented by JSON. This object stores information about loyalty tiers in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of loyalty tier objects. + attr_accessor :data_ref + + # This is an object representing a loyalty tier. Loyalty tiers are used to create a loyalty program with different levels of membership and varied earning rules and rewards based on customer’s tiers. + attr_accessor :data + + # Total number of loyalty tier objects. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesTiersListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesTiersListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_tiers_rewards_list_response_body.rb b/lib/VoucherifySdk/models/loyalties_tiers_rewards_list_response_body.rb new file mode 100644 index 00000000..84076394 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_tiers_rewards_list_response_body.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/loyalties/{campaignId}/tiers/{loyaltyTierId}/rewards`. + class LoyaltiesTiersRewardsListResponseBody + # The type of object represented by JSON. This object stores information about loyalty tier rewards in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of loyalty tier reward objects. + attr_accessor :data_ref + + # Contains array of loyalty tier reward objects. + attr_accessor :data + + # Total number of loyalty tier reward objects. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesTiersRewardsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesTiersRewardsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalties_transfer_points.rb b/lib/VoucherifySdk/models/loyalties_transfer_points.rb new file mode 100644 index 00000000..61cecc1b --- /dev/null +++ b/lib/VoucherifySdk/models/loyalties_transfer_points.rb @@ -0,0 +1,266 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltiesTransferPoints + # Unique loyalty card code from which the user wants to transfer loyalty points (source). + attr_accessor :code + + # The number of loyalty points that the user wants to transfer to another loyalty card. The number of points cannot be higher than the current balance on the loyalty card (source). + attr_accessor :points + + # Reason for the transfer. + attr_accessor :reason + + # The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'points' => :'points', + :'reason' => :'reason', + :'source_id' => :'source_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'String', + :'points' => :'Integer', + :'reason' => :'String', + :'source_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltiesTransferPoints` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltiesTransferPoints`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @source_id.nil? + invalid_properties.push('invalid value for "source_id", source_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + return false if @points.nil? + return false if @source_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code && + points == o.points && + reason == o.reason && + source_id == o.source_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [code, points, reason, source_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_card_transaction.rb b/lib/VoucherifySdk/models/loyalty_card_transaction.rb new file mode 100644 index 00000000..01dc840a --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_card_transaction.rb @@ -0,0 +1,386 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltyCardTransaction + # Unique transaction ID. + attr_accessor :id + + # The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. In case of a redemption, this value is null. + attr_accessor :source_id + + # Unique voucher ID. + attr_accessor :voucher_id + + # Unqiue campaign ID of the voucher's parent campaign if it is part of campaign that generates bulk codes. + attr_accessor :campaign_id + + # The channel through which the transaction took place, whether through the API or the the Dashboard. In case of a redemption, this value is null. + attr_accessor :source + + # Reason why the transaction occurred. In case of a redemption, this value is null. + attr_accessor :reason + + attr_accessor :type + + attr_accessor :details + + # The related transaction ID on the receiving card. + attr_accessor :related_transaction_id + + # Timestamp representing the date and time when the transaction was created in ISO 8601 format. + attr_accessor :created_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'voucher_id' => :'voucher_id', + :'campaign_id' => :'campaign_id', + :'source' => :'source', + :'reason' => :'reason', + :'type' => :'type', + :'details' => :'details', + :'related_transaction_id' => :'related_transaction_id', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'voucher_id' => :'String', + :'campaign_id' => :'String', + :'source' => :'String', + :'reason' => :'String', + :'type' => :'LoyaltyCardTransactionsType', + :'details' => :'VoucherTransactionDetails', + :'related_transaction_id' => :'String', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'source', + :'reason', + :'related_transaction_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'VoucherTransaction' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyCardTransaction` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyCardTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'voucher_id') + self.voucher_id = attributes[:'voucher_id'] + else + self.voucher_id = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + else + self.reason = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'details') + self.details = attributes[:'details'] + else + self.details = nil + end + + if attributes.key?(:'related_transaction_id') + self.related_transaction_id = attributes[:'related_transaction_id'] + else + self.related_transaction_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @voucher_id.nil? + invalid_properties.push('invalid value for "voucher_id", voucher_id cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @details.nil? + invalid_properties.push('invalid value for "details", details cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @voucher_id.nil? + return false if @campaign_id.nil? + return false if @type.nil? + return false if @details.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + voucher_id == o.voucher_id && + campaign_id == o.campaign_id && + source == o.source && + reason == o.reason && + type == o.type && + details == o.details && + related_transaction_id == o.related_transaction_id && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, voucher_id, campaign_id, source, reason, type, details, related_transaction_id, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_card_transactions_type.rb b/lib/VoucherifySdk/models/loyalty_card_transactions_type.rb new file mode 100644 index 00000000..769a8f1a --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_card_transactions_type.rb @@ -0,0 +1,47 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltyCardTransactionsType + ACCRUAL = "POINTS_ACCRUAL".freeze + CANCELLATION = "POINTS_CANCELLATION".freeze + REDEMPTION = "POINTS_REDEMPTION".freeze + REFUND = "POINTS_REFUND".freeze + ADDITION = "POINTS_ADDITION".freeze + REMOVAL = "POINTS_REMOVAL".freeze + EXPIRATION = "POINTS_EXPIRATION".freeze + TRANSFER_IN = "POINTS_TRANSFER_IN".freeze + TRANSFER_OUT = "POINTS_TRANSFER_OUT".freeze + + def self.all_vars + @all_vars ||= [ACCRUAL, CANCELLATION, REDEMPTION, REFUND, ADDITION, REMOVAL, EXPIRATION, TRANSFER_IN, TRANSFER_OUT].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if LoyaltyCardTransactionsType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #LoyaltyCardTransactionsType" + end + end +end diff --git a/lib/VoucherifySdk/models/loyalty_tier.rb b/lib/VoucherifySdk/models/loyalty_tier.rb new file mode 100644 index 00000000..087c6390 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tier.rb @@ -0,0 +1,420 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltyTier + # Loyalty Tier name. + attr_accessor :name + + # Contains a list of earning rule IDs and their points mapping for the given earning rule. + attr_accessor :earning_rules + + # Contains a list of reward IDs and their points mapping for the given reward. + attr_accessor :rewards + + attr_accessor :points + + # Unique loyalty tier ID. + attr_accessor :id + + # Unique parent campaign ID. + attr_accessor :campaign_id + + # The metadata object stores all custom attributes assigned to the loyalty tier. A set of key/value pairs that you can attach to a loyalty tier object. It can be useful for storing additional information about the loyalty tier in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the loyalty tier was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the loyalty tier was updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :config + + attr_accessor :expiration + + # The type of object represented by JSON. This object stores information about the loyalty. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'earning_rules' => :'earning_rules', + :'rewards' => :'rewards', + :'points' => :'points', + :'id' => :'id', + :'campaign_id' => :'campaign_id', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'config' => :'config', + :'expiration' => :'expiration', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'earning_rules' => :'Hash', + :'rewards' => :'Hash', + :'points' => :'LoyaltyTierBasePoints', + :'id' => :'String', + :'campaign_id' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'config' => :'LoyaltyTierAllOfConfig', + :'expiration' => :'LoyaltyTierExpiration', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'metadata', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'LoyaltyTierBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTier` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'earning_rules') + if (value = attributes[:'earning_rules']).is_a?(Hash) + self.earning_rules = value + end + end + + if attributes.key?(:'rewards') + if (value = attributes[:'rewards']).is_a?(Hash) + self.rewards = value + end + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'config') + self.config = attributes[:'config'] + else + self.config = nil + end + + if attributes.key?(:'expiration') + self.expiration = attributes[:'expiration'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'loyalty_tier' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @config.nil? + invalid_properties.push('invalid value for "config", config cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @points.nil? + return false if @id.nil? + return false if @campaign_id.nil? + return false if @created_at.nil? + return false if @config.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["loyalty_tier"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["loyalty_tier"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + earning_rules == o.earning_rules && + rewards == o.rewards && + points == o.points && + id == o.id && + campaign_id == o.campaign_id && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + config == o.config && + expiration == o.expiration && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, earning_rules, rewards, points, id, campaign_id, metadata, created_at, updated_at, config, expiration, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tier_all_of_config.rb b/lib/VoucherifySdk/models/loyalty_tier_all_of_config.rb new file mode 100644 index 00000000..41cbbb60 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tier_all_of_config.rb @@ -0,0 +1,222 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines loyalty tier range in points. + class LoyaltyTierAllOfConfig + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'LoyaltyTierAllOfConfigPoints' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTierAllOfConfig` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTierAllOfConfig`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tier_all_of_config_points.rb b/lib/VoucherifySdk/models/loyalty_tier_all_of_config_points.rb new file mode 100644 index 00000000..f8865ed7 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tier_all_of_config_points.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines range of loyalty tier in points. + class LoyaltyTierAllOfConfigPoints + # Bottom points threshold value. + attr_accessor :from + + # Top points threshold value. + attr_accessor :to + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'from' => :'from', + :'to' => :'to' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'from' => :'Integer', + :'to' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTierAllOfConfigPoints` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTierAllOfConfigPoints`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + from == o.from && + to == o.to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [from, to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tier_base.rb b/lib/VoucherifySdk/models/loyalty_tier_base.rb new file mode 100644 index 00000000..74bcce4e --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tier_base.rb @@ -0,0 +1,262 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class LoyaltyTierBase + # Loyalty Tier name. + attr_accessor :name + + # Contains a list of earning rule IDs and their points mapping for the given earning rule. + attr_accessor :earning_rules + + # Contains a list of reward IDs and their points mapping for the given reward. + attr_accessor :rewards + + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'earning_rules' => :'earning_rules', + :'rewards' => :'rewards', + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'earning_rules' => :'Hash', + :'rewards' => :'Hash', + :'points' => :'LoyaltyTierBasePoints' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTierBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTierBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'earning_rules') + if (value = attributes[:'earning_rules']).is_a?(Hash) + self.earning_rules = value + end + end + + if attributes.key?(:'rewards') + if (value = attributes[:'rewards']).is_a?(Hash) + self.rewards = value + end + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @points.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + earning_rules == o.earning_rules && + rewards == o.rewards && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, earning_rules, rewards, points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tier_base_points.rb b/lib/VoucherifySdk/models/loyalty_tier_base_points.rb new file mode 100644 index 00000000..7c6869c6 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tier_base_points.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines range of loyalty tier in points. + class LoyaltyTierBasePoints + # Bottom points threshold value. + attr_accessor :from + + # Top points threshold value. + attr_accessor :to + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'from' => :'from', + :'to' => :'to' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'from' => :'Integer', + :'to' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTierBasePoints` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTierBasePoints`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + from == o.from && + to == o.to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [from, to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tier_expiration.rb b/lib/VoucherifySdk/models/loyalty_tier_expiration.rb new file mode 100644 index 00000000..68a798dd --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tier_expiration.rb @@ -0,0 +1,304 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines loyalty tier expiration date. + class LoyaltyTierExpiration + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique campaign ID, assigned by Voucherify. + attr_accessor :campaign_id + + # Unique tier ID, assigned by Voucherify. + attr_accessor :tier_id + + # Activation timestamp defines when the loyalty tier starts to be active in ISO 8601 format. Loyalty tier is inactive before this date. + attr_accessor :start_date + + # Expiration timestamp defines when the loyalty tier expires in ISO 8601 format. Loyalty tier is inactive after this date. + attr_accessor :expiration_date + + # Timestamp representing the date and time when the loyalty tier was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the loyalty tier was updated in ISO 8601 format. + attr_accessor :updated_at + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer_id' => :'customer_id', + :'campaign_id' => :'campaign_id', + :'tier_id' => :'tier_id', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer_id' => :'String', + :'campaign_id' => :'String', + :'tier_id' => :'String', + :'start_date' => :'String', + :'expiration_date' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTierExpiration` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTierExpiration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'tier_id') + self.tier_id = attributes[:'tier_id'] + else + self.tier_id = nil + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @tier_id.nil? + invalid_properties.push('invalid value for "tier_id", tier_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @customer_id.nil? + return false if @campaign_id.nil? + return false if @tier_id.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer_id == o.customer_id && + campaign_id == o.campaign_id && + tier_id == o.tier_id && + start_date == o.start_date && + expiration_date == o.expiration_date && + created_at == o.created_at && + updated_at == o.updated_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer_id, campaign_id, tier_id, start_date, expiration_date, created_at, updated_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tiers_expiration_all.rb b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all.rb new file mode 100644 index 00000000..cf5b9a2d --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all.rb @@ -0,0 +1,311 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the Loyalty Tiers Expiration. + class LoyaltyTiersExpirationAll + # Tier qualification. `BALANCE`: Points balance is based on the customer's current points balance. Customers qualify for the tier if their points balance is in the points range of the tier. `POINTS_IN_PERIOD`: A customer qualifies for the tier only if the sum of the accumulated points in a **defined time interval** reaches the tier threshold. + attr_accessor :qualification_type + + # Customers can qualify for the tier if they collected enough points in a given time period. So, in addition to the customer having to reach a points range, they also need to have collected the points within a set time period. | **Period** | **Definition** | |:---|:---| | **Calendar Month** | Points collected in one calendar month
January, February, March, etc. | | **Calendar Quarter** | Points collected in the quarter
- January - March
- April - June
- July - September
- October - December | | **Calendar Half-year** | Points collected in the half-year
- January - June
- July - December | | **Calendar Year** | Points collected in one calendar year
January - December | + attr_accessor :qualification_period + + attr_accessor :start_date + + attr_accessor :expiration_date + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'qualification_type' => :'qualification_type', + :'qualification_period' => :'qualification_period', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'qualification_type' => :'String', + :'qualification_period' => :'String', + :'start_date' => :'LoyaltyTiersExpirationAllStartDate', + :'expiration_date' => :'LoyaltyTiersExpirationAllExpirationDate' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTiersExpirationAll` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTiersExpirationAll`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'qualification_type') + self.qualification_type = attributes[:'qualification_type'] + else + self.qualification_type = nil + end + + if attributes.key?(:'qualification_period') + self.qualification_period = attributes[:'qualification_period'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + else + self.start_date = nil + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + else + self.expiration_date = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @qualification_type.nil? + invalid_properties.push('invalid value for "qualification_type", qualification_type cannot be nil.') + end + + if @start_date.nil? + invalid_properties.push('invalid value for "start_date", start_date cannot be nil.') + end + + if @expiration_date.nil? + invalid_properties.push('invalid value for "expiration_date", expiration_date cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @qualification_type.nil? + qualification_type_validator = EnumAttributeValidator.new('String', ["BALANCE", "POINTS_IN_PERIOD"]) + return false unless qualification_type_validator.valid?(@qualification_type) + qualification_period_validator = EnumAttributeValidator.new('String', ["MONTH", "QUARTER", "HALF_YEAR", "YEAR"]) + return false unless qualification_period_validator.valid?(@qualification_period) + return false if @start_date.nil? + return false if @expiration_date.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] qualification_type Object to be assigned + def qualification_type=(qualification_type) + validator = EnumAttributeValidator.new('String', ["BALANCE", "POINTS_IN_PERIOD"]) + unless validator.valid?(qualification_type) + fail ArgumentError, "invalid value for \"qualification_type\", must be one of #{validator.allowable_values}." + end + @qualification_type = qualification_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] qualification_period Object to be assigned + def qualification_period=(qualification_period) + validator = EnumAttributeValidator.new('String', ["MONTH", "QUARTER", "HALF_YEAR", "YEAR"]) + unless validator.valid?(qualification_period) + fail ArgumentError, "invalid value for \"qualification_period\", must be one of #{validator.allowable_values}." + end + @qualification_period = qualification_period + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + qualification_type == o.qualification_type && + qualification_period == o.qualification_period && + start_date == o.start_date && + expiration_date == o.expiration_date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [qualification_type, qualification_period, start_date, expiration_date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date.rb b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date.rb new file mode 100644 index 00000000..d6876082 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the conditions for the expiration date of a tier. + class LoyaltyTiersExpirationAllExpirationDate + # What triggers the tier to expire for a customer. `END_OF_PERIOD`: Expire tier at the end of the period. `END_OF_NEXT_PERIOD`: Expire tier at the end of the next period. `BALANCE_DROP`: Tier expires when the points balance drops below the required range of the tier. `CUSTOM`: Tier expires after a certain time period passes following the instance the points balance drops below the required range of the tier. + attr_accessor :type + + # Extend the expiration by adding extra months or days in ISO 8601 format. The tier will remain active even though it reaches its expiration time period. For example, a tier with a duration of `P3M` will be valid for an additional duration of 3 months and a tier with a duration of `P1D` will be valid for an additional duration of 1 day. + attr_accessor :extend + + attr_accessor :rounding + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'extend' => :'extend', + :'rounding' => :'rounding' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'extend' => :'String', + :'rounding' => :'LoyaltyTiersExpirationAllExpirationDateRounding' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTiersExpirationAllExpirationDate` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTiersExpirationAllExpirationDate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'extend') + self.extend = attributes[:'extend'] + else + self.extend = nil + end + + if attributes.key?(:'rounding') + self.rounding = attributes[:'rounding'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @extend.nil? + invalid_properties.push('invalid value for "extend", extend cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["END_OF_PERIOD", "END_OF_NEXT_PERIOD", "BALANCE_DROP", "CUSTOM"]) + return false unless type_validator.valid?(@type) + return false if @extend.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["END_OF_PERIOD", "END_OF_NEXT_PERIOD", "BALANCE_DROP", "CUSTOM"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + extend == o.extend && + rounding == o.rounding + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, extend, rounding].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date_rounding.rb b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date_rounding.rb new file mode 100644 index 00000000..64d79e38 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_expiration_date_rounding.rb @@ -0,0 +1,306 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the rounding mechanism for tier expiration. + class LoyaltyTiersExpirationAllExpirationDateRounding + # This mechanism describes a custom rounding for the expiration date. + attr_accessor :type + + # This mechanism describes a rounding strategy for the expiration date. + attr_accessor :strategy + + # Defines the type of unit of time in which the rounding period is counted. + attr_accessor :unit + + # Value for the unit of time that the rounding applies to. Units for this parameter are defined by the `rounding.unit` parameter. - `0`: January - `1`: February - `2`: March - `3`: April - `4`: May - `5`: June - `6`: July - `7`: August - `8`: September - `9`: October - `10`: November - `11`: December + attr_accessor :value + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'strategy' => :'strategy', + :'unit' => :'unit', + :'value' => :'value' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'strategy' => :'String', + :'unit' => :'String', + :'value' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTiersExpirationAllExpirationDateRounding` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTiersExpirationAllExpirationDateRounding`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'strategy') + self.strategy = attributes[:'strategy'] + end + + if attributes.key?(:'unit') + self.unit = attributes[:'unit'] + else + self.unit = 'MONTH' + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["MONTH", "QUARTER", "HALF_YEAR", "YEAR", "CUSTOM"]) + return false unless type_validator.valid?(@type) + strategy_validator = EnumAttributeValidator.new('String', ["START", "END"]) + return false unless strategy_validator.valid?(@strategy) + unit_validator = EnumAttributeValidator.new('String', ["MONTH"]) + return false unless unit_validator.valid?(@unit) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["MONTH", "QUARTER", "HALF_YEAR", "YEAR", "CUSTOM"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] strategy Object to be assigned + def strategy=(strategy) + validator = EnumAttributeValidator.new('String', ["START", "END"]) + unless validator.valid?(strategy) + fail ArgumentError, "invalid value for \"strategy\", must be one of #{validator.allowable_values}." + end + @strategy = strategy + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] unit Object to be assigned + def unit=(unit) + validator = EnumAttributeValidator.new('String', ["MONTH"]) + unless validator.valid?(unit) + fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}." + end + @unit = unit + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + strategy == o.strategy && + unit == o.unit && + value == o.value + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, strategy, unit, value].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_start_date.rb b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_start_date.rb new file mode 100644 index 00000000..78d5dc43 --- /dev/null +++ b/lib/VoucherifySdk/models/loyalty_tiers_expiration_all_start_date.rb @@ -0,0 +1,257 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the conditions for the start date of the tier. + class LoyaltyTiersExpirationAllStartDate + # What triggers the tier to be valid for a customer. `IMMEDIATE`: After reaching the minimum required points. `NEXT_PERIOD`: When the next qualification period starts. + attr_accessor :type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LoyaltyTiersExpirationAllStartDate` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LoyaltyTiersExpirationAllStartDate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["IMMEDIATE", "NEXT_PERIOD"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["IMMEDIATE", "NEXT_PERIOD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/lucky_draw.rb b/lib/VoucherifySdk/models/lucky_draw.rb new file mode 100644 index 00000000..7803b318 --- /dev/null +++ b/lib/VoucherifySdk/models/lucky_draw.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Object for defining detailed information about lucky draw should be applied + class LuckyDraw + # It represents the total number of winners in a lucky draw. + attr_accessor :winners_count + + # It indicates whether each winner in a draw is unique or not. + attr_accessor :unique_winners_per_draw + + # Specifies whether each participant can win only once across multiple draws. + attr_accessor :unique_winners + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'winners_count' => :'winners_count', + :'unique_winners_per_draw' => :'unique_winners_per_draw', + :'unique_winners' => :'unique_winners' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'winners_count' => :'String', + :'unique_winners_per_draw' => :'String', + :'unique_winners' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::LuckyDraw` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::LuckyDraw`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'winners_count') + self.winners_count = attributes[:'winners_count'] + end + + if attributes.key?(:'unique_winners_per_draw') + self.unique_winners_per_draw = attributes[:'unique_winners_per_draw'] + end + + if attributes.key?(:'unique_winners') + self.unique_winners = attributes[:'unique_winners'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Custom attribute writer method with validation + # @param [Object] winners_count Value to be assigned + def winners_count=(winners_count) + if winners_count.nil? + fail ArgumentError, 'winners_count cannot be nil' + end + + @winners_count = winners_count + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + winners_count == o.winners_count && + unique_winners_per_draw == o.unique_winners_per_draw && + unique_winners == o.unique_winners + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [winners_count, unique_winners_per_draw, unique_winners].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/mapping_fixed.rb b/lib/VoucherifySdk/models/mapping_fixed.rb new file mode 100644 index 00000000..3b082f9d --- /dev/null +++ b/lib/VoucherifySdk/models/mapping_fixed.rb @@ -0,0 +1,261 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class MappingFixed + # Type of calculation. + attr_accessor :type + + # Fixed number of points to be applied. + attr_accessor :points + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::MappingFixed` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::MappingFixed`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'CUSTOM' + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["CUSTOM"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["CUSTOM"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/mapping_multiply.rb b/lib/VoucherifySdk/models/mapping_multiply.rb new file mode 100644 index 00000000..da5e2175 --- /dev/null +++ b/lib/VoucherifySdk/models/mapping_multiply.rb @@ -0,0 +1,261 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class MappingMultiply + # Type of calculation. + attr_accessor :type + + # Multiplication factor used to multiply the points to obtain the mapped points. + attr_accessor :multiplier + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'multiplier' => :'multiplier' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'multiplier' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::MappingMultiply` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::MappingMultiply`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'MULTIPLY' + end + + if attributes.key?(:'multiplier') + self.multiplier = attributes[:'multiplier'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["MULTIPLY", "CUSTOM"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["MULTIPLY", "CUSTOM"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + multiplier == o.multiplier + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, multiplier].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/mapping_points.rb b/lib/VoucherifySdk/models/mapping_points.rb new file mode 100644 index 00000000..7280c482 --- /dev/null +++ b/lib/VoucherifySdk/models/mapping_points.rb @@ -0,0 +1,105 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module MappingPoints + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'MappingFixed', + :'MappingMultiply' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/order.rb b/lib/VoucherifySdk/models/order.rb new file mode 100644 index 00000000..4860a46a --- /dev/null +++ b/lib/VoucherifySdk/models/order.rb @@ -0,0 +1,366 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class Order + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Array of items applied to the order. + attr_accessor :items + + attr_accessor :customer + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + attr_accessor :referrer + + # Unique referrer ID. + attr_accessor :referrer_id + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'initial_amount' => :'initial_amount', + :'items' => :'items', + :'customer' => :'customer', + :'customer_id' => :'customer_id', + :'referrer' => :'referrer', + :'referrer_id' => :'referrer_id', + :'metadata' => :'metadata', + :'id' => :'id', + :'source_id' => :'source_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'String', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'initial_amount' => :'Integer', + :'items' => :'Array', + :'customer' => :'Customer', + :'customer_id' => :'String', + :'referrer' => :'Referrer', + :'referrer_id' => :'String', + :'metadata' => :'Object', + :'id' => :'String', + :'source_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Order` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Order`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + amount == o.amount && + discount_amount == o.discount_amount && + initial_amount == o.initial_amount && + items == o.items && + customer == o.customer && + customer_id == o.customer_id && + referrer == o.referrer && + referrer_id == o.referrer_id && + metadata == o.metadata && + id == o.id && + source_id == o.source_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, amount, discount_amount, initial_amount, items, customer, customer_id, referrer, referrer_id, metadata, id, source_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_base.rb b/lib/VoucherifySdk/models/order_base.rb new file mode 100644 index 00000000..08b4ade5 --- /dev/null +++ b/lib/VoucherifySdk/models/order_base.rb @@ -0,0 +1,339 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class OrderBase + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Array of items applied to the order. + attr_accessor :items + + attr_accessor :customer + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + attr_accessor :referrer + + # Unique referrer ID. + attr_accessor :referrer_id + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'initial_amount' => :'initial_amount', + :'items' => :'items', + :'customer' => :'customer', + :'customer_id' => :'customer_id', + :'referrer' => :'referrer', + :'referrer_id' => :'referrer_id', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'String', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'initial_amount' => :'Integer', + :'items' => :'Array', + :'customer' => :'Customer', + :'customer_id' => :'String', + :'referrer' => :'Referrer', + :'referrer_id' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + amount == o.amount && + discount_amount == o.discount_amount && + initial_amount == o.initial_amount && + items == o.items && + customer == o.customer && + customer_id == o.customer_id && + referrer == o.referrer && + referrer_id == o.referrer_id && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, amount, discount_amount, initial_amount, items, customer, customer_id, referrer, referrer_id, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_calculated.rb b/lib/VoucherifySdk/models/order_calculated.rb new file mode 100644 index 00000000..2c3c7b62 --- /dev/null +++ b/lib/VoucherifySdk/models/order_calculated.rb @@ -0,0 +1,496 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class OrderCalculated + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # Timestamp representing the date and time when the order was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the order was last updated in ISO 8601 format. + attr_accessor :updated_at + + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # Sum of all product-specific discounts applied to the order. + attr_accessor :items_discount_amount + + # Sum of all order-level AND all product-specific discounts applied to the order. + attr_accessor :total_discount_amount + + # Order amount after undoing all the discounts through the rollback redemption. + attr_accessor :total_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` + attr_accessor :items_applied_discount_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Array of items applied to the order. + attr_accessor :items + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # The type of object represented by JSON. + attr_accessor :object + + attr_accessor :redemptions + + attr_accessor :customer + + attr_accessor :referrer + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'status' => :'status', + :'amount' => :'amount', + :'initial_amount' => :'initial_amount', + :'discount_amount' => :'discount_amount', + :'items_discount_amount' => :'items_discount_amount', + :'total_discount_amount' => :'total_discount_amount', + :'total_amount' => :'total_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'items_applied_discount_amount' => :'items_applied_discount_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'items' => :'items', + :'metadata' => :'metadata', + :'customer_id' => :'customer_id', + :'referrer_id' => :'referrer_id', + :'object' => :'object', + :'redemptions' => :'redemptions', + :'customer' => :'customer', + :'referrer' => :'referrer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'status' => :'String', + :'amount' => :'Integer', + :'initial_amount' => :'Integer', + :'discount_amount' => :'Integer', + :'items_discount_amount' => :'Integer', + :'total_discount_amount' => :'Integer', + :'total_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'items_applied_discount_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'items' => :'Array', + :'metadata' => :'Object', + :'customer_id' => :'String', + :'referrer_id' => :'String', + :'object' => :'String', + :'redemptions' => :'Hash', + :'customer' => :'OrderCalculatedCustomer', + :'referrer' => :'OrderCalculatedReferrer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'updated_at', + :'customer_id', + :'referrer_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderCalculatedBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderCalculated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderCalculated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'items_discount_amount') + self.items_discount_amount = attributes[:'items_discount_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'items_applied_discount_amount') + self.items_applied_discount_amount = attributes[:'items_applied_discount_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + else + self.referrer_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order' + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Hash) + self.redemptions = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + created_at == o.created_at && + updated_at == o.updated_at && + status == o.status && + amount == o.amount && + initial_amount == o.initial_amount && + discount_amount == o.discount_amount && + items_discount_amount == o.items_discount_amount && + total_discount_amount == o.total_discount_amount && + total_amount == o.total_amount && + applied_discount_amount == o.applied_discount_amount && + items_applied_discount_amount == o.items_applied_discount_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + items == o.items && + metadata == o.metadata && + customer_id == o.customer_id && + referrer_id == o.referrer_id && + object == o.object && + redemptions == o.redemptions && + customer == o.customer && + referrer == o.referrer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, created_at, updated_at, status, amount, initial_amount, discount_amount, items_discount_amount, total_discount_amount, total_amount, applied_discount_amount, items_applied_discount_amount, total_applied_discount_amount, items, metadata, customer_id, referrer_id, object, redemptions, customer, referrer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_calculated_base.rb b/lib/VoucherifySdk/models/order_calculated_base.rb new file mode 100644 index 00000000..e7e48772 --- /dev/null +++ b/lib/VoucherifySdk/models/order_calculated_base.rb @@ -0,0 +1,472 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Order information. + class OrderCalculatedBase + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # Timestamp representing the date and time when the order was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the order was last updated in ISO 8601 format. + attr_accessor :updated_at + + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # Sum of all product-specific discounts applied to the order. + attr_accessor :items_discount_amount + + # Sum of all order-level AND all product-specific discounts applied to the order. + attr_accessor :total_discount_amount + + # Order amount after undoing all the discounts through the rollback redemption. + attr_accessor :total_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` + attr_accessor :items_applied_discount_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Array of items applied to the order. + attr_accessor :items + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # The type of object represented by JSON. + attr_accessor :object + + attr_accessor :redemptions + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'status' => :'status', + :'amount' => :'amount', + :'initial_amount' => :'initial_amount', + :'discount_amount' => :'discount_amount', + :'items_discount_amount' => :'items_discount_amount', + :'total_discount_amount' => :'total_discount_amount', + :'total_amount' => :'total_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'items_applied_discount_amount' => :'items_applied_discount_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'items' => :'items', + :'metadata' => :'metadata', + :'customer_id' => :'customer_id', + :'referrer_id' => :'referrer_id', + :'object' => :'object', + :'redemptions' => :'redemptions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'status' => :'String', + :'amount' => :'Integer', + :'initial_amount' => :'Integer', + :'discount_amount' => :'Integer', + :'items_discount_amount' => :'Integer', + :'total_discount_amount' => :'Integer', + :'total_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'items_applied_discount_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'items' => :'Array', + :'metadata' => :'Object', + :'customer_id' => :'String', + :'referrer_id' => :'String', + :'object' => :'String', + :'redemptions' => :'Hash' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'updated_at', + :'customer_id', + :'referrer_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderCalculatedBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderCalculatedBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'items_discount_amount') + self.items_discount_amount = attributes[:'items_discount_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'items_applied_discount_amount') + self.items_applied_discount_amount = attributes[:'items_applied_discount_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + else + self.referrer_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order' + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Hash) + self.redemptions = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + created_at == o.created_at && + updated_at == o.updated_at && + status == o.status && + amount == o.amount && + initial_amount == o.initial_amount && + discount_amount == o.discount_amount && + items_discount_amount == o.items_discount_amount && + total_discount_amount == o.total_discount_amount && + total_amount == o.total_amount && + applied_discount_amount == o.applied_discount_amount && + items_applied_discount_amount == o.items_applied_discount_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + items == o.items && + metadata == o.metadata && + customer_id == o.customer_id && + referrer_id == o.referrer_id && + object == o.object && + redemptions == o.redemptions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, created_at, updated_at, status, amount, initial_amount, discount_amount, items_discount_amount, total_discount_amount, total_amount, applied_discount_amount, items_applied_discount_amount, total_applied_discount_amount, items, metadata, customer_id, referrer_id, object, redemptions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_calculated_customer.rb b/lib/VoucherifySdk/models/order_calculated_customer.rb new file mode 100644 index 00000000..fa1b4f9f --- /dev/null +++ b/lib/VoucherifySdk/models/order_calculated_customer.rb @@ -0,0 +1,105 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module OrderCalculatedCustomer + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'CustomerId', + :'CustomerWithSummaryLoyaltyReferrals' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/order_calculated_no_customer_data.rb b/lib/VoucherifySdk/models/order_calculated_no_customer_data.rb new file mode 100644 index 00000000..cc291dd5 --- /dev/null +++ b/lib/VoucherifySdk/models/order_calculated_no_customer_data.rb @@ -0,0 +1,496 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class OrderCalculatedNoCustomerData + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # Timestamp representing the date and time when the order was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the order was last updated in ISO 8601 format. + attr_accessor :updated_at + + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # Sum of all product-specific discounts applied to the order. + attr_accessor :items_discount_amount + + # Sum of all order-level AND all product-specific discounts applied to the order. + attr_accessor :total_discount_amount + + # Order amount after undoing all the discounts through the rollback redemption. + attr_accessor :total_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` + attr_accessor :items_applied_discount_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Array of items applied to the order. + attr_accessor :items + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # The type of object represented by JSON. + attr_accessor :object + + attr_accessor :redemptions + + attr_accessor :customer + + attr_accessor :referrer + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'status' => :'status', + :'amount' => :'amount', + :'initial_amount' => :'initial_amount', + :'discount_amount' => :'discount_amount', + :'items_discount_amount' => :'items_discount_amount', + :'total_discount_amount' => :'total_discount_amount', + :'total_amount' => :'total_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'items_applied_discount_amount' => :'items_applied_discount_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'items' => :'items', + :'metadata' => :'metadata', + :'customer_id' => :'customer_id', + :'referrer_id' => :'referrer_id', + :'object' => :'object', + :'redemptions' => :'redemptions', + :'customer' => :'customer', + :'referrer' => :'referrer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'status' => :'String', + :'amount' => :'Integer', + :'initial_amount' => :'Integer', + :'discount_amount' => :'Integer', + :'items_discount_amount' => :'Integer', + :'total_discount_amount' => :'Integer', + :'total_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'items_applied_discount_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'items' => :'Array', + :'metadata' => :'Object', + :'customer_id' => :'String', + :'referrer_id' => :'String', + :'object' => :'String', + :'redemptions' => :'Hash', + :'customer' => :'CustomerId', + :'referrer' => :'ReferrerId' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'updated_at', + :'customer_id', + :'referrer_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderCalculatedBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderCalculatedNoCustomerData` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderCalculatedNoCustomerData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'items_discount_amount') + self.items_discount_amount = attributes[:'items_discount_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'items_applied_discount_amount') + self.items_applied_discount_amount = attributes[:'items_applied_discount_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + else + self.referrer_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order' + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Hash) + self.redemptions = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + created_at == o.created_at && + updated_at == o.updated_at && + status == o.status && + amount == o.amount && + initial_amount == o.initial_amount && + discount_amount == o.discount_amount && + items_discount_amount == o.items_discount_amount && + total_discount_amount == o.total_discount_amount && + total_amount == o.total_amount && + applied_discount_amount == o.applied_discount_amount && + items_applied_discount_amount == o.items_applied_discount_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + items == o.items && + metadata == o.metadata && + customer_id == o.customer_id && + referrer_id == o.referrer_id && + object == o.object && + redemptions == o.redemptions && + customer == o.customer && + referrer == o.referrer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, created_at, updated_at, status, amount, initial_amount, discount_amount, items_discount_amount, total_discount_amount, total_amount, applied_discount_amount, items_applied_discount_amount, total_applied_discount_amount, items, metadata, customer_id, referrer_id, object, redemptions, customer, referrer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_calculated_referrer.rb b/lib/VoucherifySdk/models/order_calculated_referrer.rb new file mode 100644 index 00000000..a604e201 --- /dev/null +++ b/lib/VoucherifySdk/models/order_calculated_referrer.rb @@ -0,0 +1,105 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module OrderCalculatedReferrer + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ReferrerId', + :'ReferrerWithSummaryLoyaltyReferrals' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/order_item.rb b/lib/VoucherifySdk/models/order_item.rb new file mode 100644 index 00000000..7fca8d6c --- /dev/null +++ b/lib/VoucherifySdk/models/order_item.rb @@ -0,0 +1,377 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class OrderItem + # A unique SKU ID assigned by Voucherify. + attr_accessor :sku_id + + # A unique product ID assigned by Voucherify. + attr_accessor :product_id + + # Used along with the source_id property, can be set to either sku or product. + attr_accessor :related_object + + # The merchant’s product/SKU ID (if it is different from the Voucherify product/SKU ID). It is useful in the integration between multiple systems. It can be an ID from an eCommerce site, a database, or a third-party service. + attr_accessor :source_id + + # The quantity of the particular item in the cart. + attr_accessor :quantity + + # Number of dicounted items. + attr_accessor :discount_quantity + + # A positive integer in the smallest unit quantity representing the total amount of the order; this is the sum of the order items' quantity. + attr_accessor :initial_quantity + + # The total amount of the order item (price * quantity). + attr_accessor :amount + + # Sum of all order-item-level discounts applied to the order. + attr_accessor :discount_amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Unit price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :price + + attr_accessor :product + + attr_accessor :sku + + # A set of custom key/value pairs that you can attach to an SKU. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'sku_id' => :'sku_id', + :'product_id' => :'product_id', + :'related_object' => :'related_object', + :'source_id' => :'source_id', + :'quantity' => :'quantity', + :'discount_quantity' => :'discount_quantity', + :'initial_quantity' => :'initial_quantity', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'initial_amount' => :'initial_amount', + :'price' => :'price', + :'product' => :'product', + :'sku' => :'sku', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'sku_id' => :'String', + :'product_id' => :'String', + :'related_object' => :'String', + :'source_id' => :'String', + :'quantity' => :'Integer', + :'discount_quantity' => :'Integer', + :'initial_quantity' => :'Integer', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'initial_amount' => :'Integer', + :'price' => :'Integer', + :'product' => :'OrderItemProduct', + :'sku' => :'OrderItemSku', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'sku_id') + self.sku_id = attributes[:'sku_id'] + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'related_object') + self.related_object = attributes[:'related_object'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + + if attributes.key?(:'discount_quantity') + self.discount_quantity = attributes[:'discount_quantity'] + end + + if attributes.key?(:'initial_quantity') + self.initial_quantity = attributes[:'initial_quantity'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + related_object_validator = EnumAttributeValidator.new('String', ["product", "sku"]) + return false unless related_object_validator.valid?(@related_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object Object to be assigned + def related_object=(related_object) + validator = EnumAttributeValidator.new('String', ["product", "sku"]) + unless validator.valid?(related_object) + fail ArgumentError, "invalid value for \"related_object\", must be one of #{validator.allowable_values}." + end + @related_object = related_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + sku_id == o.sku_id && + product_id == o.product_id && + related_object == o.related_object && + source_id == o.source_id && + quantity == o.quantity && + discount_quantity == o.discount_quantity && + initial_quantity == o.initial_quantity && + amount == o.amount && + discount_amount == o.discount_amount && + initial_amount == o.initial_amount && + price == o.price && + product == o.product && + sku == o.sku && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [sku_id, product_id, related_object, source_id, quantity, discount_quantity, initial_quantity, amount, discount_amount, initial_amount, price, product, sku, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_item_calculated.rb b/lib/VoucherifySdk/models/order_item_calculated.rb new file mode 100644 index 00000000..10726f13 --- /dev/null +++ b/lib/VoucherifySdk/models/order_item_calculated.rb @@ -0,0 +1,436 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class OrderItemCalculated + # A unique SKU ID assigned by Voucherify. + attr_accessor :sku_id + + # A unique product ID assigned by Voucherify. + attr_accessor :product_id + + # Used along with the source_id property, can be set to either sku or product. + attr_accessor :related_object + + # The merchant’s product/SKU ID (if it is different from the Voucherify product/SKU ID). It is useful in the integration between multiple systems. It can be an ID from an eCommerce site, a database, or a third-party service. + attr_accessor :source_id + + # The quantity of the particular item in the cart. + attr_accessor :quantity + + # Number of dicounted items. + attr_accessor :discount_quantity + + # A positive integer in the smallest unit quantity representing the total amount of the order; this is the sum of the order items' quantity. + attr_accessor :initial_quantity + + # The total amount of the order item (price * quantity). + attr_accessor :amount + + # Sum of all order-item-level discounts applied to the order. + attr_accessor :discount_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Unit price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :price + + # Final order item amount after the applied item-level discount. If there are no item-level discounts applied, this item is equal to the `amount`. `subtotal_amount`=`amount`-`applied_discount_amount` + attr_accessor :subtotal_amount + + attr_accessor :product + + attr_accessor :sku + + # The type of object represented by JSON. + attr_accessor :object + + # A set of custom key/value pairs that you can attach to an SKU. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'sku_id' => :'sku_id', + :'product_id' => :'product_id', + :'related_object' => :'related_object', + :'source_id' => :'source_id', + :'quantity' => :'quantity', + :'discount_quantity' => :'discount_quantity', + :'initial_quantity' => :'initial_quantity', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'initial_amount' => :'initial_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'price' => :'price', + :'subtotal_amount' => :'subtotal_amount', + :'product' => :'product', + :'sku' => :'sku', + :'object' => :'object', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'sku_id' => :'String', + :'product_id' => :'String', + :'related_object' => :'String', + :'source_id' => :'String', + :'quantity' => :'Integer', + :'discount_quantity' => :'Integer', + :'initial_quantity' => :'Integer', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'initial_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'price' => :'Integer', + :'subtotal_amount' => :'Integer', + :'product' => :'OrderItemProduct', + :'sku' => :'OrderItemSku', + :'object' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderItemCalculated` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderItemCalculated`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'sku_id') + self.sku_id = attributes[:'sku_id'] + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'related_object') + self.related_object = attributes[:'related_object'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + + if attributes.key?(:'discount_quantity') + self.discount_quantity = attributes[:'discount_quantity'] + end + + if attributes.key?(:'initial_quantity') + self.initial_quantity = attributes[:'initial_quantity'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'subtotal_amount') + self.subtotal_amount = attributes[:'subtotal_amount'] + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order_item' + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + related_object_validator = EnumAttributeValidator.new('String', ["product", "sku"]) + return false unless related_object_validator.valid?(@related_object) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order_item"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object Object to be assigned + def related_object=(related_object) + validator = EnumAttributeValidator.new('String', ["product", "sku"]) + unless validator.valid?(related_object) + fail ArgumentError, "invalid value for \"related_object\", must be one of #{validator.allowable_values}." + end + @related_object = related_object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order_item"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + sku_id == o.sku_id && + product_id == o.product_id && + related_object == o.related_object && + source_id == o.source_id && + quantity == o.quantity && + discount_quantity == o.discount_quantity && + initial_quantity == o.initial_quantity && + amount == o.amount && + discount_amount == o.discount_amount && + applied_discount_amount == o.applied_discount_amount && + initial_amount == o.initial_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + price == o.price && + subtotal_amount == o.subtotal_amount && + product == o.product && + sku == o.sku && + object == o.object && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [sku_id, product_id, related_object, source_id, quantity, discount_quantity, initial_quantity, amount, discount_amount, applied_discount_amount, initial_amount, total_applied_discount_amount, price, subtotal_amount, product, sku, object, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_item_product.rb b/lib/VoucherifySdk/models/order_item_product.rb new file mode 100644 index 00000000..a8b97c03 --- /dev/null +++ b/lib/VoucherifySdk/models/order_item_product.rb @@ -0,0 +1,266 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # An object containing details of the related product. + class OrderItemProduct + # A unique identifier that represents the product and is assigned by Voucherify. + attr_accessor :id + + # The merchant’s product ID (if it is different than Voucherify's product ID). It is really useful in case of integration between multiple systems. It can be an ID from an eCommerce site, a database or a 3rd party service. + attr_accessor :source_id + + # The override set to `true` is used to store the product information in the system. If the product does not exist, it will be created with a source_id; if it does exist, the provided values for the name, price, and metadata will replace those already stored in the system. + attr_accessor :override + + # Product name. + attr_accessor :name + + # A set of custom key/value pairs that you can attach to a product. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # Product price. A positive integer in the smallest currency unit (e.g. 100 cents for $1.00). + attr_accessor :price + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'override' => :'override', + :'name' => :'name', + :'metadata' => :'metadata', + :'price' => :'price' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'override' => :'Boolean', + :'name' => :'String', + :'metadata' => :'Object', + :'price' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderItemProduct` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderItemProduct`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'override') + self.override = attributes[:'override'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + override == o.override && + name == o.name && + metadata == o.metadata && + price == o.price + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, override, name, metadata, price].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_item_sku.rb b/lib/VoucherifySdk/models/order_item_sku.rb new file mode 100644 index 00000000..6d9f6f76 --- /dev/null +++ b/lib/VoucherifySdk/models/order_item_sku.rb @@ -0,0 +1,256 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # An object containing details of the related SKU. + class OrderItemSku + # A unique identifier that represents the SKU and is assigned by Voucherify. + attr_accessor :id + + # The merchant’s SKU ID (if it is different than Voucherify's SKU ID). It is really useful in case of integration between multiple systems. It can be an ID from an eCommerce site, a database or a 3rd party service. + attr_accessor :source_id + + # The override set to `true` is used to store the product information in the system. If the product does not exist, it will be created with a source_id; if it does exist, the provided values for the name, price, and metadata will replace those already stored in the system. + attr_accessor :override + + # The SKU name. + attr_accessor :sku + + # SKU price. A positive integer in the smallest currency unit (e.g. 100 cents for $1.00). + attr_accessor :price + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'override' => :'override', + :'sku' => :'sku', + :'price' => :'price' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'override' => :'Boolean', + :'sku' => :'String', + :'price' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderItemSku` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderItemSku`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'override') + self.override = attributes[:'override'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + override == o.override && + sku == o.sku && + price == o.price + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, override, sku, price].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/order_redemptions.rb b/lib/VoucherifySdk/models/order_redemptions.rb new file mode 100644 index 00000000..f5387207 --- /dev/null +++ b/lib/VoucherifySdk/models/order_redemptions.rb @@ -0,0 +1,291 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class OrderRedemptions + # Timestamp representing the date and time when the redemption was created in ISO 8601 format. + attr_accessor :date + + # Unique ID of the redemption rollback. + attr_accessor :rollback_id + + # Timestamp representing the date and tiem when the redemption rollback was created in ISO 8601 format. + attr_accessor :rollback_date + + # The source of the incentive. + attr_accessor :related_object_type + + # Unique ID of the parent redemption. + attr_accessor :related_object_id + + # Represent's the campaign ID of the voucher if the redemption was based on a voucher that was part of bulk codes generated within a campaign. In case of a promotion tier, this represents the campaign ID of the promotion tier's parent campaign. + attr_accessor :related_object_parent_id + + # Contains a list of unique IDs of child redemptions, which belong to the stacked incentives. + attr_accessor :stacked + + # Lists the rollback redemption IDs of the particular child redemptions. + attr_accessor :rollback_stacked + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'date' => :'date', + :'rollback_id' => :'rollback_id', + :'rollback_date' => :'rollback_date', + :'related_object_type' => :'related_object_type', + :'related_object_id' => :'related_object_id', + :'related_object_parent_id' => :'related_object_parent_id', + :'stacked' => :'stacked', + :'rollback_stacked' => :'rollback_stacked' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'date' => :'Time', + :'rollback_id' => :'String', + :'rollback_date' => :'Time', + :'related_object_type' => :'String', + :'related_object_id' => :'String', + :'related_object_parent_id' => :'String', + :'stacked' => :'Array', + :'rollback_stacked' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrderRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrderRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + + if attributes.key?(:'rollback_id') + self.rollback_id = attributes[:'rollback_id'] + end + + if attributes.key?(:'rollback_date') + self.rollback_date = attributes[:'rollback_date'] + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'redemption' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + end + + if attributes.key?(:'related_object_parent_id') + self.related_object_parent_id = attributes[:'related_object_parent_id'] + end + + if attributes.key?(:'stacked') + if (value = attributes[:'stacked']).is_a?(Array) + self.stacked = value + end + end + + if attributes.key?(:'rollback_stacked') + if (value = attributes[:'rollback_stacked']).is_a?(Array) + self.rollback_stacked = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + date == o.date && + rollback_id == o.rollback_id && + rollback_date == o.rollback_date && + related_object_type == o.related_object_type && + related_object_id == o.related_object_id && + related_object_parent_id == o.related_object_parent_id && + stacked == o.stacked && + rollback_stacked == o.rollback_stacked + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [date, rollback_id, rollback_date, related_object_type, related_object_id, related_object_parent_id, stacked, rollback_stacked].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_create_request_body.rb b/lib/VoucherifySdk/models/orders_create_request_body.rb new file mode 100644 index 00000000..f49a0916 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_create_request_body.rb @@ -0,0 +1,367 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/orders`. + class OrdersCreateRequestBody + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Array of items applied to the order. + attr_accessor :items + + attr_accessor :customer + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + attr_accessor :referrer + + # Unique referrer ID. + attr_accessor :referrer_id + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'status' => :'status', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'initial_amount' => :'initial_amount', + :'items' => :'items', + :'customer' => :'customer', + :'customer_id' => :'customer_id', + :'referrer' => :'referrer', + :'referrer_id' => :'referrer_id', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'status' => :'String', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'initial_amount' => :'Integer', + :'items' => :'Array', + :'customer' => :'Customer', + :'customer_id' => :'String', + :'referrer' => :'Referrer', + :'referrer_id' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Order' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + status == o.status && + amount == o.amount && + discount_amount == o.discount_amount && + initial_amount == o.initial_amount && + items == o.items && + customer == o.customer && + customer_id == o.customer_id && + referrer == o.referrer && + referrer_id == o.referrer_id && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, status, amount, discount_amount, initial_amount, items, customer, customer_id, referrer, referrer_id, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_create_response_body.rb b/lib/VoucherifySdk/models/orders_create_response_body.rb new file mode 100644 index 00000000..603b1ee8 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_create_response_body.rb @@ -0,0 +1,497 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/orders`. + class OrdersCreateResponseBody + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # Timestamp representing the date and time when the order was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the order was last updated in ISO 8601 format. + attr_accessor :updated_at + + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # Sum of all product-specific discounts applied to the order. + attr_accessor :items_discount_amount + + # Sum of all order-level AND all product-specific discounts applied to the order. + attr_accessor :total_discount_amount + + # Order amount after undoing all the discounts through the rollback redemption. + attr_accessor :total_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` + attr_accessor :items_applied_discount_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Array of items applied to the order. + attr_accessor :items + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # The type of object represented by JSON. + attr_accessor :object + + attr_accessor :redemptions + + attr_accessor :customer + + attr_accessor :referrer + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'status' => :'status', + :'amount' => :'amount', + :'initial_amount' => :'initial_amount', + :'discount_amount' => :'discount_amount', + :'items_discount_amount' => :'items_discount_amount', + :'total_discount_amount' => :'total_discount_amount', + :'total_amount' => :'total_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'items_applied_discount_amount' => :'items_applied_discount_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'items' => :'items', + :'metadata' => :'metadata', + :'customer_id' => :'customer_id', + :'referrer_id' => :'referrer_id', + :'object' => :'object', + :'redemptions' => :'redemptions', + :'customer' => :'customer', + :'referrer' => :'referrer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'status' => :'String', + :'amount' => :'Integer', + :'initial_amount' => :'Integer', + :'discount_amount' => :'Integer', + :'items_discount_amount' => :'Integer', + :'total_discount_amount' => :'Integer', + :'total_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'items_applied_discount_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'items' => :'Array', + :'metadata' => :'Object', + :'customer_id' => :'String', + :'referrer_id' => :'String', + :'object' => :'String', + :'redemptions' => :'Hash', + :'customer' => :'OrderCalculatedCustomer', + :'referrer' => :'OrderCalculatedReferrer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'updated_at', + :'customer_id', + :'referrer_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderCalculated' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'items_discount_amount') + self.items_discount_amount = attributes[:'items_discount_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'items_applied_discount_amount') + self.items_applied_discount_amount = attributes[:'items_applied_discount_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + else + self.referrer_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order' + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Hash) + self.redemptions = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + created_at == o.created_at && + updated_at == o.updated_at && + status == o.status && + amount == o.amount && + initial_amount == o.initial_amount && + discount_amount == o.discount_amount && + items_discount_amount == o.items_discount_amount && + total_discount_amount == o.total_discount_amount && + total_amount == o.total_amount && + applied_discount_amount == o.applied_discount_amount && + items_applied_discount_amount == o.items_applied_discount_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + items == o.items && + metadata == o.metadata && + customer_id == o.customer_id && + referrer_id == o.referrer_id && + object == o.object && + redemptions == o.redemptions && + customer == o.customer && + referrer == o.referrer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, created_at, updated_at, status, amount, initial_amount, discount_amount, items_discount_amount, total_discount_amount, total_amount, applied_discount_amount, items_applied_discount_amount, total_applied_discount_amount, items, metadata, customer_id, referrer_id, object, redemptions, customer, referrer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_export_create_request_body.rb b/lib/VoucherifySdk/models/orders_export_create_request_body.rb new file mode 100644 index 00000000..67a9e494 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_export_create_request_body.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/orders/export`. + class OrdersExportCreateRequestBody + attr_accessor :parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'parameters' => :'OrdersExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersExportCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersExportCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_export_create_request_body_parameters.rb b/lib/VoucherifySdk/models/orders_export_create_request_body_parameters.rb new file mode 100644 index 00000000..3076f666 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_export_create_request_body_parameters.rb @@ -0,0 +1,259 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with an order along with the sorting order of the returned data. + class OrdersExportCreateRequestBodyParameters + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. + attr_accessor :fields + + # Allowed additional properties must start with \"metadata.\" + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'ExportOrderOrder', + :'fields' => :'Array', + :'filters' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersExportCreateRequestBodyParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersExportCreateRequestBodyParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_export_create_response_body.rb b/lib/VoucherifySdk/models/orders_export_create_response_body.rb new file mode 100644 index 00000000..177214c3 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_export_create_response_body.rb @@ -0,0 +1,406 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/orders/export`. + class OrdersExportCreateResponseBody + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the export. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # Contains the URL of the CSV file. + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the channel value is WEBSITE. + attr_accessor :user_id + + # The type of object to be exported. + attr_accessor :exported_object + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'result' => :'result', + :'user_id' => :'user_id', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'result' => :'Object', + :'user_id' => :'String', + :'exported_object' => :'String', + :'parameters' => :'OrdersExportCreateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ExportOrderBase', + :'ExportScheduledBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersExportCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersExportCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'order' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @user_id.nil? + invalid_properties.push('invalid value for "user_id", user_id cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @user_id.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless exported_object_validator.valid?(@exported_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + result == o.result && + user_id == o.user_id && + exported_object == o.exported_object && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, result, user_id, exported_object, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_get_response_body.rb b/lib/VoucherifySdk/models/orders_get_response_body.rb new file mode 100644 index 00000000..f8f737c1 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_get_response_body.rb @@ -0,0 +1,497 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/orders/{orderId}`. + class OrdersGetResponseBody + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # Timestamp representing the date and time when the order was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the order was last updated in ISO 8601 format. + attr_accessor :updated_at + + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # Sum of all product-specific discounts applied to the order. + attr_accessor :items_discount_amount + + # Sum of all order-level AND all product-specific discounts applied to the order. + attr_accessor :total_discount_amount + + # Order amount after undoing all the discounts through the rollback redemption. + attr_accessor :total_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` + attr_accessor :items_applied_discount_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Array of items applied to the order. + attr_accessor :items + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # The type of object represented by JSON. + attr_accessor :object + + attr_accessor :redemptions + + attr_accessor :customer + + attr_accessor :referrer + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'status' => :'status', + :'amount' => :'amount', + :'initial_amount' => :'initial_amount', + :'discount_amount' => :'discount_amount', + :'items_discount_amount' => :'items_discount_amount', + :'total_discount_amount' => :'total_discount_amount', + :'total_amount' => :'total_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'items_applied_discount_amount' => :'items_applied_discount_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'items' => :'items', + :'metadata' => :'metadata', + :'customer_id' => :'customer_id', + :'referrer_id' => :'referrer_id', + :'object' => :'object', + :'redemptions' => :'redemptions', + :'customer' => :'customer', + :'referrer' => :'referrer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'status' => :'String', + :'amount' => :'Integer', + :'initial_amount' => :'Integer', + :'discount_amount' => :'Integer', + :'items_discount_amount' => :'Integer', + :'total_discount_amount' => :'Integer', + :'total_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'items_applied_discount_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'items' => :'Array', + :'metadata' => :'Object', + :'customer_id' => :'String', + :'referrer_id' => :'String', + :'object' => :'String', + :'redemptions' => :'Hash', + :'customer' => :'CustomerId', + :'referrer' => :'ReferrerId' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'updated_at', + :'customer_id', + :'referrer_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderCalculatedNoCustomerData' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'items_discount_amount') + self.items_discount_amount = attributes[:'items_discount_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'items_applied_discount_amount') + self.items_applied_discount_amount = attributes[:'items_applied_discount_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + else + self.referrer_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order' + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Hash) + self.redemptions = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + created_at == o.created_at && + updated_at == o.updated_at && + status == o.status && + amount == o.amount && + initial_amount == o.initial_amount && + discount_amount == o.discount_amount && + items_discount_amount == o.items_discount_amount && + total_discount_amount == o.total_discount_amount && + total_amount == o.total_amount && + applied_discount_amount == o.applied_discount_amount && + items_applied_discount_amount == o.items_applied_discount_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + items == o.items && + metadata == o.metadata && + customer_id == o.customer_id && + referrer_id == o.referrer_id && + object == o.object && + redemptions == o.redemptions && + customer == o.customer && + referrer == o.referrer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, created_at, updated_at, status, amount, initial_amount, discount_amount, items_discount_amount, total_discount_amount, total_amount, applied_discount_amount, items_applied_discount_amount, total_applied_discount_amount, items, metadata, customer_id, referrer_id, object, redemptions, customer, referrer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_import_create_request_body_item.rb b/lib/VoucherifySdk/models/orders_import_create_request_body_item.rb new file mode 100644 index 00000000..54b32761 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_import_create_request_body_item.rb @@ -0,0 +1,356 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class OrdersImportCreateRequestBodyItem + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Array of items applied to the order. + attr_accessor :items + + attr_accessor :customer + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + attr_accessor :referrer + + # Unique referrer ID. + attr_accessor :referrer_id + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'initial_amount' => :'initial_amount', + :'items' => :'items', + :'customer' => :'customer', + :'customer_id' => :'customer_id', + :'referrer' => :'referrer', + :'referrer_id' => :'referrer_id', + :'metadata' => :'metadata', + :'source_id' => :'source_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'String', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'initial_amount' => :'Integer', + :'items' => :'Array', + :'customer' => :'Customer', + :'customer_id' => :'String', + :'referrer' => :'Referrer', + :'referrer_id' => :'String', + :'metadata' => :'Object', + :'source_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersImportCreateRequestBodyItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersImportCreateRequestBodyItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + amount == o.amount && + discount_amount == o.discount_amount && + initial_amount == o.initial_amount && + items == o.items && + customer == o.customer && + customer_id == o.customer_id && + referrer == o.referrer && + referrer_id == o.referrer_id && + metadata == o.metadata && + source_id == o.source_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, amount, discount_amount, initial_amount, items, customer, customer_id, referrer, referrer_id, metadata, source_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_import_create_response_body.rb b/lib/VoucherifySdk/models/orders_import_create_response_body.rb new file mode 100644 index 00000000..69cebbbb --- /dev/null +++ b/lib/VoucherifySdk/models/orders_import_create_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/orders/import`. + class OrdersImportCreateResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersImportCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersImportCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_list_response_body.rb b/lib/VoucherifySdk/models/orders_list_response_body.rb new file mode 100644 index 00000000..10815c4a --- /dev/null +++ b/lib/VoucherifySdk/models/orders_list_response_body.rb @@ -0,0 +1,322 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema representing **GET** `/orders`. + class OrdersListResponseBody + # The type of object represented by JSON. This object stores information about orders in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of order objects. + attr_accessor :data_ref + + # Contains array of order objects. + attr_accessor :orders + + # Total number of orders. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'orders' => :'orders', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'orders' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'orders' + end + + if attributes.key?(:'orders') + if (value = attributes[:'orders']).is_a?(Array) + self.orders = value + end + else + self.orders = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @orders.nil? + invalid_properties.push('invalid value for "orders", orders cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["orders"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @orders.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["orders"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + orders == o.orders && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, orders, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_update_request_body.rb b/lib/VoucherifySdk/models/orders_update_request_body.rb new file mode 100644 index 00000000..93243e38 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_update_request_body.rb @@ -0,0 +1,347 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **PUT** `/orders/{orderId}`. + class OrdersUpdateRequestBody + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Array of items applied to the order. + attr_accessor :items + + attr_accessor :customer + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + attr_accessor :referrer + + # Unique referrer ID. + attr_accessor :referrer_id + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'initial_amount' => :'initial_amount', + :'items' => :'items', + :'customer' => :'customer', + :'customer_id' => :'customer_id', + :'referrer' => :'referrer', + :'referrer_id' => :'referrer_id', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'String', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'initial_amount' => :'Integer', + :'items' => :'Array', + :'customer' => :'Customer', + :'customer_id' => :'String', + :'referrer' => :'Referrer', + :'referrer_id' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + amount == o.amount && + discount_amount == o.discount_amount && + initial_amount == o.initial_amount && + items == o.items && + customer == o.customer && + customer_id == o.customer_id && + referrer == o.referrer && + referrer_id == o.referrer_id && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, amount, discount_amount, initial_amount, items, customer, customer_id, referrer, referrer_id, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/orders_update_response_body.rb b/lib/VoucherifySdk/models/orders_update_response_body.rb new file mode 100644 index 00000000..fafdd179 --- /dev/null +++ b/lib/VoucherifySdk/models/orders_update_response_body.rb @@ -0,0 +1,497 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/orders/{orderId}`. + class OrdersUpdateResponseBody + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # Timestamp representing the date and time when the order was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the order was last updated in ISO 8601 format. + attr_accessor :updated_at + + # The order status. + attr_accessor :status + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :initial_amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # Sum of all product-specific discounts applied to the order. + attr_accessor :items_discount_amount + + # Sum of all order-level AND all product-specific discounts applied to the order. + attr_accessor :total_discount_amount + + # Order amount after undoing all the discounts through the rollback redemption. + attr_accessor :total_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` + attr_accessor :items_applied_discount_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Array of items applied to the order. + attr_accessor :items + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # The type of object represented by JSON. + attr_accessor :object + + attr_accessor :redemptions + + attr_accessor :customer + + attr_accessor :referrer + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'status' => :'status', + :'amount' => :'amount', + :'initial_amount' => :'initial_amount', + :'discount_amount' => :'discount_amount', + :'items_discount_amount' => :'items_discount_amount', + :'total_discount_amount' => :'total_discount_amount', + :'total_amount' => :'total_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'items_applied_discount_amount' => :'items_applied_discount_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'items' => :'items', + :'metadata' => :'metadata', + :'customer_id' => :'customer_id', + :'referrer_id' => :'referrer_id', + :'object' => :'object', + :'redemptions' => :'redemptions', + :'customer' => :'customer', + :'referrer' => :'referrer' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'status' => :'String', + :'amount' => :'Integer', + :'initial_amount' => :'Integer', + :'discount_amount' => :'Integer', + :'items_discount_amount' => :'Integer', + :'total_discount_amount' => :'Integer', + :'total_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'items_applied_discount_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'items' => :'Array', + :'metadata' => :'Object', + :'customer_id' => :'String', + :'referrer_id' => :'String', + :'object' => :'String', + :'redemptions' => :'Hash', + :'customer' => :'OrderCalculatedCustomer', + :'referrer' => :'OrderCalculatedReferrer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'updated_at', + :'customer_id', + :'referrer_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'OrderCalculated' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::OrdersUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::OrdersUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'initial_amount') + self.initial_amount = attributes[:'initial_amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'items_discount_amount') + self.items_discount_amount = attributes[:'items_discount_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'items_applied_discount_amount') + self.items_applied_discount_amount = attributes[:'items_applied_discount_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + else + self.referrer_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order' + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Hash) + self.redemptions = value + end + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'referrer') + self.referrer = attributes[:'referrer'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + created_at == o.created_at && + updated_at == o.updated_at && + status == o.status && + amount == o.amount && + initial_amount == o.initial_amount && + discount_amount == o.discount_amount && + items_discount_amount == o.items_discount_amount && + total_discount_amount == o.total_discount_amount && + total_amount == o.total_amount && + applied_discount_amount == o.applied_discount_amount && + items_applied_discount_amount == o.items_applied_discount_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + items == o.items && + metadata == o.metadata && + customer_id == o.customer_id && + referrer_id == o.referrer_id && + object == o.object && + redemptions == o.redemptions && + customer == o.customer && + referrer == o.referrer + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, created_at, updated_at, status, amount, initial_amount, discount_amount, items_discount_amount, total_discount_amount, total_amount, applied_discount_amount, items_applied_discount_amount, total_applied_discount_amount, items, metadata, customer_id, referrer_id, object, redemptions, customer, referrer].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_campaign_type.rb b/lib/VoucherifySdk/models/parameter_campaign_type.rb new file mode 100644 index 00000000..5878f4be --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_campaign_type.rb @@ -0,0 +1,44 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterCampaignType + PROMOTION = "PROMOTION".freeze + GIFT_VOUCHERS = "GIFT_VOUCHERS".freeze + REFERRAL_PROGRAM = "REFERRAL_PROGRAM".freeze + DISCOUNT_COUPONS = "DISCOUNT_COUPONS".freeze + LOYALTY_PROGRAM = "LOYALTY_PROGRAM".freeze + LUCKY_DRAW = "LUCKY_DRAW".freeze + + def self.all_vars + @all_vars ||= [PROMOTION, GIFT_VOUCHERS, REFERRAL_PROGRAM, DISCOUNT_COUPONS, LOYALTY_PROGRAM, LUCKY_DRAW].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterCampaignType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterCampaignType" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_created_before_after.rb b/lib/VoucherifySdk/models/parameter_created_before_after.rb new file mode 100644 index 00000000..5bd54de1 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_created_before_after.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterCreatedBeforeAfter + # Timestamp representing the date and time before the voucher was created in ISO 8601 format. + attr_accessor :before + + # Timestamp representing the date and time after the voucher was created in ISO 8601 format. + attr_accessor :after + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'before' => :'before', + :'after' => :'after' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'before' => :'Time', + :'after' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterCreatedBeforeAfter` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterCreatedBeforeAfter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'before') + self.before = attributes[:'before'] + end + + if attributes.key?(:'after') + self.after = attributes[:'after'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + before == o.before && + after == o.after + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [before, after].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_expand_list_campaigns.rb b/lib/VoucherifySdk/models/parameter_expand_list_campaigns.rb new file mode 100644 index 00000000..a219ced2 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_expand_list_campaigns.rb @@ -0,0 +1,39 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterExpandListCampaigns + CATEGORY = "category".freeze + + def self.all_vars + @all_vars ||= [CATEGORY].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterExpandListCampaigns.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterExpandListCampaigns" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions.rb new file mode 100644 index 00000000..3f2b0c32 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions.rb @@ -0,0 +1,295 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterFiltersListRedemptions + attr_accessor :voucher_code + + attr_accessor :related_object_id + + attr_accessor :related_object_parent_id + + attr_accessor :parent_redemption_id + + attr_accessor :failure_code + + attr_accessor :result + + attr_accessor :object + + attr_accessor :customer_id + + attr_accessor :campaign_name + + attr_accessor :user_login + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'voucher_code' => :'voucher_code', + :'related_object_id' => :'related_object_id', + :'related_object_parent_id' => :'related_object_parent_id', + :'parent_redemption_id' => :'parent_redemption_id', + :'failure_code' => :'failure_code', + :'result' => :'result', + :'object' => :'object', + :'customer_id' => :'customer_id', + :'campaign_name' => :'campaign_name', + :'user_login' => :'user_login' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'voucher_code' => :'ParameterFiltersListRedemptionsVoucherCode', + :'related_object_id' => :'ParameterFiltersListRedemptionsRelatedObjectId', + :'related_object_parent_id' => :'ParameterFiltersListRedemptionsRelatedObjectParentId', + :'parent_redemption_id' => :'ParameterFiltersListRedemptionsParentRedemptionId', + :'failure_code' => :'ParameterFiltersListRedemptionsFailureCode', + :'result' => :'ParameterFiltersListRedemptionsResult', + :'object' => :'ParameterFiltersListRedemptionsObject', + :'customer_id' => :'ParameterFiltersListRedemptionsCustomerId', + :'campaign_name' => :'ParameterFiltersListRedemptionsCampaignName', + :'user_login' => :'ParameterFiltersListRedemptionsUserLogin' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'voucher_code') + self.voucher_code = attributes[:'voucher_code'] + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + end + + if attributes.key?(:'related_object_parent_id') + self.related_object_parent_id = attributes[:'related_object_parent_id'] + end + + if attributes.key?(:'parent_redemption_id') + self.parent_redemption_id = attributes[:'parent_redemption_id'] + end + + if attributes.key?(:'failure_code') + self.failure_code = attributes[:'failure_code'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'campaign_name') + self.campaign_name = attributes[:'campaign_name'] + end + + if attributes.key?(:'user_login') + self.user_login = attributes[:'user_login'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + voucher_code == o.voucher_code && + related_object_id == o.related_object_id && + related_object_parent_id == o.related_object_parent_id && + parent_redemption_id == o.parent_redemption_id && + failure_code == o.failure_code && + result == o.result && + object == o.object && + customer_id == o.customer_id && + campaign_name == o.campaign_name && + user_login == o.user_login + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [voucher_code, related_object_id, related_object_parent_id, parent_redemption_id, failure_code, result, object, customer_id, campaign_name, user_login].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_campaign_name.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_campaign_name.rb new file mode 100644 index 00000000..952fe3c6 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_campaign_name.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Campaign name. + class ParameterFiltersListRedemptionsCampaignName + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsCampaignName` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsCampaignName`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_customer_id.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_customer_id.rb new file mode 100644 index 00000000..c3df8c50 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_customer_id.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Unique customer ID, i.e. cust_sehkNIi8Uq2qQuRqSr7xn4Zi. + class ParameterFiltersListRedemptionsCustomerId + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsCustomerId` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsCustomerId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_failure_code.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_failure_code.rb new file mode 100644 index 00000000..65820356 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_failure_code.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Failure code, i.e. quantity_exceeded. + class ParameterFiltersListRedemptionsFailureCode + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsFailureCode` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsFailureCode`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_object.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_object.rb new file mode 100644 index 00000000..df278844 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_object.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Specify which type of object to return, i.e. `redemption` or `redemption_rollback`. + class ParameterFiltersListRedemptionsObject + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsObject` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_parent_redemption_id.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_parent_redemption_id.rb new file mode 100644 index 00000000..e2481483 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_parent_redemption_id.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Unique parent redemption ID, i.e. r_0c5952900bcbfd54b6. + class ParameterFiltersListRedemptionsParentRedemptionId + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsParentRedemptionId` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsParentRedemptionId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_related_object_id.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_related_object_id.rb new file mode 100644 index 00000000..3ae731ef --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_related_object_id.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Unique related object ID, i.e. v_hS8JFl8S6lNcd1L69wLIoXgTio7eWEgk. + class ParameterFiltersListRedemptionsRelatedObjectId + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectId` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_related_object_parent_id.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_related_object_parent_id.rb new file mode 100644 index 00000000..635a8a72 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_related_object_parent_id.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Unique related object parent ID, i.e. camp_22noMlhTADb7Fq2UL3vWu3d1. + class ParameterFiltersListRedemptionsRelatedObjectParentId + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectParentId` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsRelatedObjectParentId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_result.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_result.rb new file mode 100644 index 00000000..3e3fb1d5 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_result.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Result, i.e. `SUCCESS` or `FAILURE`. + class ParameterFiltersListRedemptionsResult + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_user_login.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_user_login.rb new file mode 100644 index 00000000..af9b8ac7 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_user_login.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # User login used to login to Voucherify, i.e. name.lastname@email.com + class ParameterFiltersListRedemptionsUserLogin + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsUserLogin` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsUserLogin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_filters_list_redemptions_voucher_code.rb b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_voucher_code.rb new file mode 100644 index 00000000..bdf6579a --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_filters_list_redemptions_voucher_code.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Unique voucher code. + class ParameterFiltersListRedemptionsVoucherCode + attr_accessor :conditions + + attr_accessor :junction + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions', + :'junction' => :'junction' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'FilterConditionsString', + :'junction' => :'Junction' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterFiltersListRedemptionsVoucherCode` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterFiltersListRedemptionsVoucherCode`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions && + junction == o.junction + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions, junction].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_order.rb b/lib/VoucherifySdk/models/parameter_order.rb new file mode 100644 index 00000000..1a91b8da --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order.rb @@ -0,0 +1,50 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrder + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + UPDATED_AT = "updated_at".freeze + UPDATED_AT2 = "-updated_at".freeze + TYPE = "type".freeze + TYPE2 = "-type".freeze + CODE = "code".freeze + CODE2 = "-code".freeze + CAMPAIGN = "campaign".freeze + CAMPAIGN2 = "-campaign".freeze + CATEGORY = "category".freeze + CATEGORY2 = "-category".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2, TYPE, TYPE2, CODE, CODE2, CAMPAIGN, CAMPAIGN2, CATEGORY, CATEGORY2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrder.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrder" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_all_promotion_stacks.rb b/lib/VoucherifySdk/models/parameter_order_list_all_promotion_stacks.rb new file mode 100644 index 00000000..330a1216 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_all_promotion_stacks.rb @@ -0,0 +1,44 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListAllPromotionStacks + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + UPDATED_AT = "updated_at".freeze + UPDATED_AT2 = "-updated_at".freeze + NAME = "name".freeze + NAME2 = "-name".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2, NAME, NAME2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListAllPromotionStacks.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListAllPromotionStacks" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_campaigns.rb b/lib/VoucherifySdk/models/parameter_order_list_campaigns.rb new file mode 100644 index 00000000..83c47500 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_campaigns.rb @@ -0,0 +1,42 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListCampaigns + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + UPDATED_AT = "updated_at".freeze + UPDATED_AT2 = "-updated_at".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListCampaigns.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListCampaigns" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_customers.rb b/lib/VoucherifySdk/models/parameter_order_list_customers.rb new file mode 100644 index 00000000..10822f75 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_customers.rb @@ -0,0 +1,44 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListCustomers + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + UPDATED_AT = "updated_at".freeze + UPDATED_AT2 = "-updated_at".freeze + SOURCE_ID = "source_id".freeze + SOURCE_ID2 = "-source_id".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2, SOURCE_ID, SOURCE_ID2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListCustomers.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListCustomers" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_exports.rb b/lib/VoucherifySdk/models/parameter_order_list_exports.rb new file mode 100644 index 00000000..00ff315e --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_exports.rb @@ -0,0 +1,42 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListExports + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + STATUS = "status".freeze + STATUS2 = "-status".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, STATUS, STATUS2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListExports.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListExports" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_loyalty_tiers.rb b/lib/VoucherifySdk/models/parameter_order_list_loyalty_tiers.rb new file mode 100644 index 00000000..9bd38e08 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_loyalty_tiers.rb @@ -0,0 +1,42 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListLoyaltyTiers + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + UPDATED_AT = "updated_at".freeze + UPDATED_AT2 = "-updated_at".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListLoyaltyTiers.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListLoyaltyTiers" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_orders.rb b/lib/VoucherifySdk/models/parameter_order_list_orders.rb new file mode 100644 index 00000000..07ea4d30 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_orders.rb @@ -0,0 +1,42 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListOrders + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + UPDATED_AT = "updated_at".freeze + UPDATED_AT2 = "-updated_at".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListOrders.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListOrders" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_publications.rb b/lib/VoucherifySdk/models/parameter_order_list_publications.rb new file mode 100644 index 00000000..a03bb23c --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_publications.rb @@ -0,0 +1,50 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListPublications + ID = "id".freeze + ID2 = "-id".freeze + VOUCHER_CODE = "voucher_code".freeze + VOUCHER_CODE2 = "-voucher_code".freeze + TRACKING_ID = "tracking_id".freeze + TRACKING_ID2 = "-tracking_id".freeze + CUSTOMER_ID = "customer_id".freeze + CUSTOMER_ID2 = "-customer_id".freeze + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + CHANNEL = "channel".freeze + CHANNEL2 = "-channel".freeze + + def self.all_vars + @all_vars ||= [ID, ID2, VOUCHER_CODE, VOUCHER_CODE2, TRACKING_ID, TRACKING_ID2, CUSTOMER_ID, CUSTOMER_ID2, CREATED_AT, CREATED_AT2, CHANNEL, CHANNEL2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListPublications.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListPublications" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_redemptions.rb b/lib/VoucherifySdk/models/parameter_order_list_redemptions.rb new file mode 100644 index 00000000..b7e1af64 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_redemptions.rb @@ -0,0 +1,48 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListRedemptions + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + ID = "id".freeze + ID2 = "-id".freeze + VOUCHER_CODE = "voucher_code".freeze + VOUCHER_CODE2 = "-voucher_code".freeze + TRACKING_ID = "tracking_id".freeze + TRACKING_ID2 = "-tracking_id".freeze + CUSTOMER_ID = "customer_id".freeze + CUSTOMER_ID2 = "-customer_id".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, ID, ID2, VOUCHER_CODE, VOUCHER_CODE2, TRACKING_ID, TRACKING_ID2, CUSTOMER_ID, CUSTOMER_ID2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListRedemptions.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListRedemptions" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_validation_rule_assignments.rb b/lib/VoucherifySdk/models/parameter_order_list_validation_rule_assignments.rb new file mode 100644 index 00000000..00c88d8d --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_validation_rule_assignments.rb @@ -0,0 +1,40 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListValidationRuleAssignments + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListValidationRuleAssignments.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListValidationRuleAssignments" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_order_list_validation_rules.rb b/lib/VoucherifySdk/models/parameter_order_list_validation_rules.rb new file mode 100644 index 00000000..70a681c1 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_order_list_validation_rules.rb @@ -0,0 +1,44 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterOrderListValidationRules + CREATED_AT = "created_at".freeze + CREATED_AT2 = "-created_at".freeze + UPDATED_AT = "updated_at".freeze + UPDATED_AT2 = "-updated_at".freeze + NAME = "name".freeze + NAME2 = "-name".freeze + + def self.all_vars + @all_vars ||= [CREATED_AT, CREATED_AT2, UPDATED_AT, UPDATED_AT2, NAME, NAME2].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterOrderListValidationRules.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterOrderListValidationRules" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_result_list_publications.rb b/lib/VoucherifySdk/models/parameter_result_list_publications.rb new file mode 100644 index 00000000..e370bc02 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_result_list_publications.rb @@ -0,0 +1,40 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterResultListPublications + SUCCESS = "SUCCESS".freeze + FAILURE = "FAILURE".freeze + + def self.all_vars + @all_vars ||= [SUCCESS, FAILURE].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterResultListPublications.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterResultListPublications" + end + end +end diff --git a/lib/VoucherifySdk/models/parameter_updated_before_after.rb b/lib/VoucherifySdk/models/parameter_updated_before_after.rb new file mode 100644 index 00000000..9209a1e2 --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_updated_before_after.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterUpdatedBeforeAfter + # Timestamp representing the date and time before the voucher was updated in ISO 8601 format. + attr_accessor :before + + # Timestamp representing the date and time after the voucher was updated in ISO 8601 format. + attr_accessor :after + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'before' => :'before', + :'after' => :'after' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'before' => :'Time', + :'after' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ParameterUpdatedBeforeAfter` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ParameterUpdatedBeforeAfter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'before') + self.before = attributes[:'before'] + end + + if attributes.key?(:'after') + self.after = attributes[:'after'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + before == o.before && + after == o.after + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [before, after].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/parameter_voucher_type_list_publications.rb b/lib/VoucherifySdk/models/parameter_voucher_type_list_publications.rb new file mode 100644 index 00000000..949d331b --- /dev/null +++ b/lib/VoucherifySdk/models/parameter_voucher_type_list_publications.rb @@ -0,0 +1,41 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ParameterVoucherTypeListPublications + DISCOUNT = "discount".freeze + LOYALTY = "loyalty".freeze + LUCKY_DRAW = "lucky_draw".freeze + + def self.all_vars + @all_vars ||= [DISCOUNT, LOYALTY, LUCKY_DRAW].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ParameterVoucherTypeListPublications.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ParameterVoucherTypeListPublications" + end + end +end diff --git a/lib/VoucherifySdk/models/points_expiration_types.rb b/lib/VoucherifySdk/models/points_expiration_types.rb new file mode 100644 index 00000000..ecbc128f --- /dev/null +++ b/lib/VoucherifySdk/models/points_expiration_types.rb @@ -0,0 +1,41 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class PointsExpirationTypes + PROGRAM_RULES = "PROGRAM_RULES".freeze + CUSTOM_DATE = "CUSTOM_DATE".freeze + NON_EXPIRING = "NON_EXPIRING".freeze + + def self.all_vars + @all_vars ||= [PROGRAM_RULES, CUSTOM_DATE, NON_EXPIRING].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if PointsExpirationTypes.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #PointsExpirationTypes" + end + end +end diff --git a/lib/VoucherifySdk/models/product.rb b/lib/VoucherifySdk/models/product.rb new file mode 100644 index 00000000..19406486 --- /dev/null +++ b/lib/VoucherifySdk/models/product.rb @@ -0,0 +1,397 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a product. This entity should be used to map product items from your inventory management system. The aim of products is to build which reflect product-specific campaigns. + class Product + # Unique product ID assigned by Voucherify. + attr_accessor :id + + # Unique product source ID. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Timestamp representing the date and time when the product was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the product was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the product. + attr_accessor :object + + attr_accessor :skus + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'skus' => :'skus' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'skus' => :'SkusListForProduct' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'name', + :'price', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ProductWithoutSkus' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Product` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Product`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + else + self.attributes = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'product' + end + + if attributes.key?(:'skus') + self.skus = attributes[:'skus'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + skus == o.skus + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, price, attributes, metadata, image_url, created_at, updated_at, object, skus].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body.rb b/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body.rb new file mode 100644 index 00000000..efc5c1a5 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body.rb @@ -0,0 +1,290 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/product-collections`. + class ProductCollectionsCreateDynamicRequestBody + # Show that the product collection is dynamic (products come in and leave based on set criteria). + attr_accessor :type + + # Unique user-defined product collection name. + attr_accessor :name + + attr_accessor :filter + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'name' => :'name', + :'filter' => :'filter' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'name' => :'String', + :'filter' => :'ProductCollectionsCreateDynamicRequestBodyFilter' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsCreateDynamicRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsCreateDynamicRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'AUTO_UPDATE' + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'filter') + self.filter = attributes[:'filter'] + else + self.filter = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @filter.nil? + invalid_properties.push('invalid value for "filter", filter cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE"]) + return false unless type_validator.valid?(@type) + return false if @name.nil? + return false if @filter.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + name == o.name && + filter == o.filter + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, name, filter].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body_filter.rb b/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body_filter.rb new file mode 100644 index 00000000..55690873 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body_filter.rb @@ -0,0 +1,352 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines a set of criteria and boundary conditions for an `AUTO_UPDATE` product collection type. + class ProductCollectionsCreateDynamicRequestBodyFilter + attr_accessor :junction + + attr_accessor :id + + attr_accessor :product_id + + attr_accessor :source_id + + attr_accessor :name + + attr_accessor :price + + attr_accessor :object + + attr_accessor :attributes + + attr_accessor :metadata + + attr_accessor :image_url + + attr_accessor :skus + + attr_accessor :created_at + + attr_accessor :updated_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'junction' => :'junction', + :'id' => :'id', + :'product_id' => :'product_id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'object' => :'object', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url', + :'skus' => :'skus', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'junction' => :'Junction', + :'id' => :'FieldConditions', + :'product_id' => :'FieldConditions', + :'source_id' => :'FieldConditions', + :'name' => :'FieldConditions', + :'price' => :'FieldConditions', + :'object' => :'FieldConditions', + :'attributes' => :'FieldConditions', + :'metadata' => :'FieldConditions', + :'image_url' => :'FieldConditions', + :'skus' => :'FieldConditions', + :'created_at' => :'FieldConditions', + :'updated_at' => :'FieldConditions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyFilter` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyFilter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + else + self.junction = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'skus') + self.skus = attributes[:'skus'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @junction.nil? + invalid_properties.push('invalid value for "junction", junction cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @junction.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + junction == o.junction && + id == o.id && + product_id == o.product_id && + source_id == o.source_id && + name == o.name && + price == o.price && + object == o.object && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url && + skus == o.skus && + created_at == o.created_at && + updated_at == o.updated_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [junction, id, product_id, source_id, name, price, object, attributes, metadata, image_url, skus, created_at, updated_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body_products_item.rb b/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body_products_item.rb new file mode 100644 index 00000000..947ac911 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_create_dynamic_request_body_products_item.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ProductCollectionsCreateDynamicRequestBodyProductsItem + # The product ID. + attr_accessor :id + + # Product ID for SKUs. + attr_accessor :product_id + + # Denotes the type of object represented by the ID. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'product_id' => :'product_id', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'product_id' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyProductsItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsCreateDynamicRequestBodyProductsItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku", "product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku", "product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + product_id == o.product_id && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, product_id, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_create_request_body.rb b/lib/VoucherifySdk/models/product_collections_create_request_body.rb new file mode 100644 index 00000000..0217c394 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_create_request_body.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/product-collections`. + module ProductCollectionsCreateRequestBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ProductCollectionsCreateDynamicRequestBody', + :'ProductCollectionsCreateStaticRequestBody' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_create_response_body.rb b/lib/VoucherifySdk/models/product_collections_create_response_body.rb new file mode 100644 index 00000000..6776319d --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_create_response_body.rb @@ -0,0 +1,365 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/product-collections`. + class ProductCollectionsCreateResponseBody + # Product collection ID. + attr_accessor :id + + # Unique user-defined product collection name. + attr_accessor :name + + # Describes whether the product collection is dynamic (products come in and leave based on set criteria) or static (manually selected products). + attr_accessor :type + + attr_accessor :filter + + # Defines a set of products for a `STATIC` product collection type. + attr_accessor :products + + # Timestamp representing the date and time when the product collection was created in ISO 8601 format. + attr_accessor :created_at + + # The type of object represented by JSON. This object stores information about the static product collection. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'type' => :'type', + :'filter' => :'filter', + :'products' => :'products', + :'created_at' => :'created_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'type' => :'String', + :'filter' => :'ProductCollectionsCreateDynamicRequestBodyFilter', + :'products' => :'Array', + :'created_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ProductCollectionsItem' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'filter') + self.filter = attributes[:'filter'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'products_collection' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + return false unless type_validator.valid?(@type) + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["products_collection"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["products_collection"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + type == o.type && + filter == o.filter && + products == o.products && + created_at == o.created_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, type, filter, products, created_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_create_static_request_body.rb b/lib/VoucherifySdk/models/product_collections_create_static_request_body.rb new file mode 100644 index 00000000..853e8b49 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_create_static_request_body.rb @@ -0,0 +1,286 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/product-collections`. + class ProductCollectionsCreateStaticRequestBody + # Show that the product collection is static (manually selected products). + attr_accessor :type + + # Unique user-defined product collection name. + attr_accessor :name + + # Defines a set of products for a `STATIC` product collection type. + attr_accessor :products + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'name' => :'name', + :'products' => :'products' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'name' => :'String', + :'products' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsCreateStaticRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsCreateStaticRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'STATIC' + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + return false unless type_validator.valid?(@type) + return false if @name.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + name == o.name && + products == o.products + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, name, products].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_get_response_body.rb b/lib/VoucherifySdk/models/product_collections_get_response_body.rb new file mode 100644 index 00000000..c48f55a3 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_get_response_body.rb @@ -0,0 +1,365 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/product-collections/{productCollectionId}`. + class ProductCollectionsGetResponseBody + # Product collection ID. + attr_accessor :id + + # Unique user-defined product collection name. + attr_accessor :name + + # Describes whether the product collection is dynamic (products come in and leave based on set criteria) or static (manually selected products). + attr_accessor :type + + attr_accessor :filter + + # Defines a set of products for a `STATIC` product collection type. + attr_accessor :products + + # Timestamp representing the date and time when the product collection was created in ISO 8601 format. + attr_accessor :created_at + + # The type of object represented by JSON. This object stores information about the static product collection. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'type' => :'type', + :'filter' => :'filter', + :'products' => :'products', + :'created_at' => :'created_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'type' => :'String', + :'filter' => :'ProductCollectionsCreateDynamicRequestBodyFilter', + :'products' => :'Array', + :'created_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ProductCollectionsItem' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'filter') + self.filter = attributes[:'filter'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'products_collection' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + return false unless type_validator.valid?(@type) + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["products_collection"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["products_collection"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + type == o.type && + filter == o.filter && + products == o.products && + created_at == o.created_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, type, filter, products, created_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_item.rb b/lib/VoucherifySdk/models/product_collections_item.rb new file mode 100644 index 00000000..357541e8 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_item.rb @@ -0,0 +1,358 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a product collection base. + class ProductCollectionsItem + # Product collection ID. + attr_accessor :id + + # Unique user-defined product collection name. + attr_accessor :name + + # Describes whether the product collection is dynamic (products come in and leave based on set criteria) or static (manually selected products). + attr_accessor :type + + attr_accessor :filter + + # Defines a set of products for a `STATIC` product collection type. + attr_accessor :products + + # Timestamp representing the date and time when the product collection was created in ISO 8601 format. + attr_accessor :created_at + + # The type of object represented by JSON. This object stores information about the static product collection. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'type' => :'type', + :'filter' => :'filter', + :'products' => :'products', + :'created_at' => :'created_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'type' => :'String', + :'filter' => :'ProductCollectionsCreateDynamicRequestBodyFilter', + :'products' => :'Array', + :'created_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'filter') + self.filter = attributes[:'filter'] + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'products_collection' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + return false unless type_validator.valid?(@type) + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["products_collection"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["STATIC", "AUTO_UPDATE"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["products_collection"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + type == o.type && + filter == o.filter && + products == o.products && + created_at == o.created_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, type, filter, products, created_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_item_products_item.rb b/lib/VoucherifySdk/models/product_collections_item_products_item.rb new file mode 100644 index 00000000..817a7f98 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_item_products_item.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ProductCollectionsItemProductsItem + # The product ID. + attr_accessor :id + + # Product ID for SKUs. + attr_accessor :product_id + + # Denotes the type of object represented by the ID. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'product_id' => :'product_id', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'product_id' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsItemProductsItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsItemProductsItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku", "product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku", "product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + product_id == o.product_id && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, product_id, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_list.rb b/lib/VoucherifySdk/models/product_collections_list.rb new file mode 100644 index 00000000..15416b89 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_list.rb @@ -0,0 +1,322 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Schema representing list of product collections + class ProductCollectionsList + # The type of object represented by JSON. This object stores information about product collections. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of product collections. + attr_accessor :data_ref + + # A dictionary that contains an array of product collections and their details. + attr_accessor :data + + # Total number of product collections. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_list_response_body.rb b/lib/VoucherifySdk/models/product_collections_list_response_body.rb new file mode 100644 index 00000000..c5b46a62 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_list_response_body.rb @@ -0,0 +1,329 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/product-collections`. + class ProductCollectionsListResponseBody + # The type of object represented by JSON. This object stores information about product collections. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of product collections. + attr_accessor :data_ref + + # A dictionary that contains an array of product collections and their details. + attr_accessor :data + + # Total number of product collections. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ProductCollectionsList' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_products_list.rb b/lib/VoucherifySdk/models/product_collections_products_list.rb new file mode 100644 index 00000000..cb58759e --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_products_list.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** /product-collections/{productCollectionID}/products. + class ProductCollectionsProductsList + # The type of object represented by JSON. This object stores information about products and SKUs. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of products and SKUs. + attr_accessor :data_ref + + # A dictionary that contains an array of products and SKUs. + attr_accessor :data + + # Total number of products & SKUs in the product collection. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsProductsList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsProductsList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_products_list_products_item.rb b/lib/VoucherifySdk/models/product_collections_products_list_products_item.rb new file mode 100644 index 00000000..c47f3775 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_products_list_products_item.rb @@ -0,0 +1,105 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module ProductCollectionsProductsListProductsItem + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ProductWithoutSkus', + :'SkuWithProduct' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/product_collections_products_list_response_body.rb b/lib/VoucherifySdk/models/product_collections_products_list_response_body.rb new file mode 100644 index 00000000..260adba2 --- /dev/null +++ b/lib/VoucherifySdk/models/product_collections_products_list_response_body.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/product-collections/{productCollectionId}/products`. + class ProductCollectionsProductsListResponseBody + # The type of object represented by JSON. This object stores information about products and SKUs. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of products and SKUs. + attr_accessor :data_ref + + # A dictionary that contains an array of products and SKUs. + attr_accessor :data + + # Total number of products & SKUs in the product collection. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ProductCollectionsProductsList' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductCollectionsProductsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductCollectionsProductsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/product_without_skus.rb b/lib/VoucherifySdk/models/product_without_skus.rb new file mode 100644 index 00000000..98aff177 --- /dev/null +++ b/lib/VoucherifySdk/models/product_without_skus.rb @@ -0,0 +1,380 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ProductWithoutSkus + # Unique product ID assigned by Voucherify. + attr_accessor :id + + # Unique product source ID. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Timestamp representing the date and time when the product was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the product was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the product. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'name', + :'price', + :'image_url', + :'updated_at', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductWithoutSkus` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductWithoutSkus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + else + self.attributes = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'product' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, price, attributes, metadata, image_url, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_create_request_body.rb b/lib/VoucherifySdk/models/products_create_request_body.rb new file mode 100644 index 00000000..ecfc8c14 --- /dev/null +++ b/lib/VoucherifySdk/models/products_create_request_body.rb @@ -0,0 +1,278 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request schema for **POST** `/products`. + class ProductsCreateRequestBody + # A unique identifier that represents the product and is assigned by Voucherify. + attr_accessor :id + + # Unique product source ID. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, price, attributes, metadata, image_url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_create_response_body.rb b/lib/VoucherifySdk/models/products_create_response_body.rb new file mode 100644 index 00000000..35778c02 --- /dev/null +++ b/lib/VoucherifySdk/models/products_create_response_body.rb @@ -0,0 +1,397 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/products`. + class ProductsCreateResponseBody + # Unique product ID assigned by Voucherify. + attr_accessor :id + + # Unique product source ID. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Timestamp representing the date and time when the product was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the product was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the product. + attr_accessor :object + + attr_accessor :skus + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'skus' => :'skus' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'skus' => :'SkusListForProduct' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'name', + :'price', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Product' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + else + self.attributes = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'product' + end + + if attributes.key?(:'skus') + self.skus = attributes[:'skus'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + skus == o.skus + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, price, attributes, metadata, image_url, created_at, updated_at, object, skus].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_get_response_body.rb b/lib/VoucherifySdk/models/products_get_response_body.rb new file mode 100644 index 00000000..c00dce63 --- /dev/null +++ b/lib/VoucherifySdk/models/products_get_response_body.rb @@ -0,0 +1,397 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/products/{productId}`. + class ProductsGetResponseBody + # Unique product ID assigned by Voucherify. + attr_accessor :id + + # Unique product source ID. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Timestamp representing the date and time when the product was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the product was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the product. + attr_accessor :object + + attr_accessor :skus + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'skus' => :'skus' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'skus' => :'SkusListForProduct' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'name', + :'price', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Product' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + else + self.attributes = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'product' + end + + if attributes.key?(:'skus') + self.skus = attributes[:'skus'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + skus == o.skus + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, price, attributes, metadata, image_url, created_at, updated_at, object, skus].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_import_csv_create_response_body.rb b/lib/VoucherifySdk/models/products_import_csv_create_response_body.rb new file mode 100644 index 00000000..26068f70 --- /dev/null +++ b/lib/VoucherifySdk/models/products_import_csv_create_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/products/importCSV`. + class ProductsImportCsvCreateResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsImportCsvCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsImportCsvCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_list_response_body.rb b/lib/VoucherifySdk/models/products_list_response_body.rb new file mode 100644 index 00000000..a1320cdc --- /dev/null +++ b/lib/VoucherifySdk/models/products_list_response_body.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/products`. + class ProductsListResponseBody + # The type of object represented by JSON. This object stores information about products in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of product objects. + attr_accessor :data_ref + + # Contains array of product objects. + attr_accessor :products + + # Total number of product objects. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'products' => :'products', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'products' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'products' + end + + if attributes.key?(:'products') + if (value = attributes[:'products']).is_a?(Array) + self.products = value + end + else + self.products = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @products.nil? + invalid_properties.push('invalid value for "products", products cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @products.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + products == o.products && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, products, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_metadata_update_in_bulk_request_body.rb b/lib/VoucherifySdk/models/products_metadata_update_in_bulk_request_body.rb new file mode 100644 index 00000000..44ca54ec --- /dev/null +++ b/lib/VoucherifySdk/models/products_metadata_update_in_bulk_request_body.rb @@ -0,0 +1,242 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request schema for **POST** `/products/metadata/async`. + class ProductsMetadataUpdateInBulkRequestBody + # Array of unique product source IDs. + attr_accessor :source_ids + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'source_ids' => :'source_ids', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'source_ids' => :'Array', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsMetadataUpdateInBulkRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsMetadataUpdateInBulkRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'source_ids') + if (value = attributes[:'source_ids']).is_a?(Array) + self.source_ids = value + end + else + self.source_ids = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @source_ids.nil? + invalid_properties.push('invalid value for "source_ids", source_ids cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @source_ids.nil? + return false if @metadata.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + source_ids == o.source_ids && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [source_ids, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_metadata_update_in_bulk_response_body.rb b/lib/VoucherifySdk/models/products_metadata_update_in_bulk_response_body.rb new file mode 100644 index 00000000..89060bf3 --- /dev/null +++ b/lib/VoucherifySdk/models/products_metadata_update_in_bulk_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/products/metadata/async`. + class ProductsMetadataUpdateInBulkResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsMetadataUpdateInBulkResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsMetadataUpdateInBulkResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_skus_create_request_body.rb b/lib/VoucherifySdk/models/products_skus_create_request_body.rb new file mode 100644 index 00000000..69341c2a --- /dev/null +++ b/lib/VoucherifySdk/models/products_skus_create_request_body.rb @@ -0,0 +1,286 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/products/{productId}/skus + class ProductsSkusCreateRequestBody + # Unique SKU ID. + attr_accessor :id + + # A unique SKU identifier from your inventory system. + attr_accessor :source_id + + # Unique user-defined SKU name. + attr_accessor :sku + + # SKU unit price. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsSkusCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsSkusCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, sku, price, currency, attributes, image_url, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_skus_create_response_body.rb b/lib/VoucherifySdk/models/products_skus_create_response_body.rb new file mode 100644 index 00000000..7aa03f72 --- /dev/null +++ b/lib/VoucherifySdk/models/products_skus_create_response_body.rb @@ -0,0 +1,425 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/products/{productId}/skus`. + class ProductsSkusCreateResponseBody + # A unique identifier that represents the SKU and is assigned by Voucherify. + attr_accessor :id + + # A unique SKU identifier from your inventory system. + attr_accessor :source_id + + # The parent product's unique ID. + attr_accessor :product_id + + # Unique user-defined SKU name. + attr_accessor :sku + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the SKU was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the SKU was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the `SKU`. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'sku', + :'price', + :'currency', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Sku' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsSkusCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsSkusCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + else + self.product_id = nil + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + else + self.sku = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + else + self.attributes = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + else + self.image_url = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'sku' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @product_id.nil? + invalid_properties.push('invalid value for "product_id", product_id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @product_id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, product_id, sku, price, currency, attributes, image_url, metadata, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_skus_list_response_body.rb b/lib/VoucherifySdk/models/products_skus_list_response_body.rb new file mode 100644 index 00000000..258cd226 --- /dev/null +++ b/lib/VoucherifySdk/models/products_skus_list_response_body.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/products/{productId}/skus`. + class ProductsSkusListResponseBody + # The type of object represented by JSON. This object stores information about SKUs. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of SKUs. + attr_accessor :data_ref + + # A dictionary that contains an array of SKUs. + attr_accessor :skus + + # Total number of SKUs in the product. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'skus' => :'skus', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'skus' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'SkusList' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsSkusListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsSkusListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'skus') + if (value = attributes[:'skus']).is_a?(Array) + self.skus = value + end + else + self.skus = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @skus.nil? + invalid_properties.push('invalid value for "skus", skus cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @skus.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + skus == o.skus && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, skus, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_skus_update_request_body.rb b/lib/VoucherifySdk/models/products_skus_update_request_body.rb new file mode 100644 index 00000000..b1276499 --- /dev/null +++ b/lib/VoucherifySdk/models/products_skus_update_request_body.rb @@ -0,0 +1,266 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **PUT** `/products/{productId}/skus/{skuId}`. + class ProductsSkusUpdateRequestBody + # Unique user-defined SKU name. + attr_accessor :sku + + # SKU unit price. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsSkusUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsSkusUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [sku, price, currency, attributes, image_url, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_skus_update_response_body.rb b/lib/VoucherifySdk/models/products_skus_update_response_body.rb new file mode 100644 index 00000000..8734b9a7 --- /dev/null +++ b/lib/VoucherifySdk/models/products_skus_update_response_body.rb @@ -0,0 +1,425 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/products/{productId}/skus/{skuId}`. + class ProductsSkusUpdateResponseBody + # A unique identifier that represents the SKU and is assigned by Voucherify. + attr_accessor :id + + # A unique SKU identifier from your inventory system. + attr_accessor :source_id + + # The parent product's unique ID. + attr_accessor :product_id + + # Unique user-defined SKU name. + attr_accessor :sku + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the SKU was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the SKU was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the `SKU`. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'sku', + :'price', + :'currency', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Sku' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsSkusUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsSkusUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + else + self.product_id = nil + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + else + self.sku = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + else + self.attributes = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + else + self.image_url = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'sku' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @product_id.nil? + invalid_properties.push('invalid value for "product_id", product_id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @product_id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, product_id, sku, price, currency, attributes, image_url, metadata, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_update_in_bulk_request_body.rb b/lib/VoucherifySdk/models/products_update_in_bulk_request_body.rb new file mode 100644 index 00000000..b487d463 --- /dev/null +++ b/lib/VoucherifySdk/models/products_update_in_bulk_request_body.rb @@ -0,0 +1,275 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request schema for **POST** `/products/bulk/async`. + class ProductsUpdateInBulkRequestBody + # Unique product source ID from your inventory system. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'image_url' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsUpdateInBulkRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsUpdateInBulkRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @source_id.nil? + invalid_properties.push('invalid value for "source_id", source_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @source_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [source_id, name, price, attributes, image_url, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_update_in_bulk_response_body.rb b/lib/VoucherifySdk/models/products_update_in_bulk_response_body.rb new file mode 100644 index 00000000..97aefe6b --- /dev/null +++ b/lib/VoucherifySdk/models/products_update_in_bulk_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/products/bulk/async`. + class ProductsUpdateInBulkResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsUpdateInBulkResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsUpdateInBulkResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_update_request_body.rb b/lib/VoucherifySdk/models/products_update_request_body.rb new file mode 100644 index 00000000..8f693254 --- /dev/null +++ b/lib/VoucherifySdk/models/products_update_request_body.rb @@ -0,0 +1,258 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request schema for **PUT** `/products`. + class ProductsUpdateRequestBody + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, price, attributes, metadata, image_url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/products_update_response_body.rb b/lib/VoucherifySdk/models/products_update_response_body.rb new file mode 100644 index 00000000..74222e9f --- /dev/null +++ b/lib/VoucherifySdk/models/products_update_response_body.rb @@ -0,0 +1,397 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/products/{productId}`. + class ProductsUpdateResponseBody + # Unique product ID assigned by Voucherify. + attr_accessor :id + + # Unique product source ID. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Timestamp representing the date and time when the product was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the product was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the product. + attr_accessor :object + + attr_accessor :skus + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'skus' => :'skus' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'skus' => :'SkusListForProduct' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'name', + :'price', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Product' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ProductsUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ProductsUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + else + self.attributes = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'product' + end + + if attributes.key?(:'skus') + self.skus = attributes[:'skus'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + skus == o.skus + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, price, attributes, metadata, image_url, created_at, updated_at, object, skus].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_stack.rb b/lib/VoucherifySdk/models/promotion_stack.rb new file mode 100644 index 00000000..efb6d0b7 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_stack.rb @@ -0,0 +1,389 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class PromotionStack + # Promotion stack name. + attr_accessor :name + + attr_accessor :tiers + + # Unique promotion stack ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the promotion stack was updated in ISO 8601 format. + attr_accessor :updated_at + + # Promotion stack's parent campaign's unique ID. + attr_accessor :campaign_id + + # The type of object represented by JSON. + attr_accessor :object + + # Promotion stack category ID. + attr_accessor :category_id + + # Details about the category assigned to the promotion stack. + attr_accessor :categories + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'tiers' => :'tiers', + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'campaign_id' => :'campaign_id', + :'object' => :'object', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'tiers' => :'PromotionStackBaseTiers', + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'campaign_id' => :'String', + :'object' => :'String', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionStackBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionStack` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionStack`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'tiers') + self.tiers = attributes[:'tiers'] + else + self.tiers = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_stack' + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @tiers.nil? + invalid_properties.push('invalid value for "tiers", tiers cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @tiers.nil? + return false if @id.nil? + return false if @created_at.nil? + return false if @campaign_id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + return false unless object_validator.valid?(@object) + return false if @categories.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + tiers == o.tiers && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + campaign_id == o.campaign_id && + object == o.object && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, tiers, id, created_at, updated_at, campaign_id, object, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_stack_base.rb b/lib/VoucherifySdk/models/promotion_stack_base.rb new file mode 100644 index 00000000..ed3c1c15 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_stack_base.rb @@ -0,0 +1,238 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class PromotionStackBase + # Promotion stack name. + attr_accessor :name + + attr_accessor :tiers + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'tiers' => :'tiers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'tiers' => :'PromotionStackBaseTiers' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionStackBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionStackBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'tiers') + self.tiers = attributes[:'tiers'] + else + self.tiers = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @tiers.nil? + invalid_properties.push('invalid value for "tiers", tiers cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @tiers.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + tiers == o.tiers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, tiers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_stack_base_tiers.rb b/lib/VoucherifySdk/models/promotion_stack_base_tiers.rb new file mode 100644 index 00000000..300dd287 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_stack_base_tiers.rb @@ -0,0 +1,289 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the tier configuration. + class PromotionStackBaseTiers + # Contains the list of tiers in a pre-defined sequence. + attr_accessor :ids + + attr_accessor :hierarchy_mode + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'ids' => :'ids', + :'hierarchy_mode' => :'hierarchy_mode' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'ids' => :'Array', + :'hierarchy_mode' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionStackBaseTiers` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionStackBaseTiers`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'ids') + if (value = attributes[:'ids']).is_a?(Array) + self.ids = value + end + else + self.ids = nil + end + + if attributes.key?(:'hierarchy_mode') + self.hierarchy_mode = attributes[:'hierarchy_mode'] + else + self.hierarchy_mode = 'MANUAL' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @ids.nil? + invalid_properties.push('invalid value for "ids", ids cannot be nil.') + end + + if @ids.length < 1 + invalid_properties.push('invalid value for "ids", number of items must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @ids.nil? + return false if @ids.length < 1 + hierarchy_mode_validator = EnumAttributeValidator.new('String', ["MANUAL"]) + return false unless hierarchy_mode_validator.valid?(@hierarchy_mode) + true + end + + # Custom attribute writer method with validation + # @param [Object] ids Value to be assigned + def ids=(ids) + if ids.nil? + fail ArgumentError, 'ids cannot be nil' + end + + if ids.length < 1 + fail ArgumentError, 'invalid value for "ids", number of items must be greater than or equal to 1.' + end + + @ids = ids + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] hierarchy_mode Object to be assigned + def hierarchy_mode=(hierarchy_mode) + validator = EnumAttributeValidator.new('String', ["MANUAL"]) + unless validator.valid?(hierarchy_mode) + fail ArgumentError, "invalid value for \"hierarchy_mode\", must be one of #{validator.allowable_values}." + end + @hierarchy_mode = hierarchy_mode + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + ids == o.ids && + hierarchy_mode == o.hierarchy_mode + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [ids, hierarchy_mode].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier.rb b/lib/VoucherifySdk/models/promotion_tier.rb new file mode 100644 index 00000000..70c85ec1 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier.rb @@ -0,0 +1,416 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a promotion tier. Promotion tiers are always assigned to a campaign and cannot be used standalone. + class PromotionTier + # Unique promotion tier ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. + attr_accessor :updated_at + + # Name of the promotion tier. + attr_accessor :name + + # Text to be displayed to your customers on your website. + attr_accessor :banner + + attr_accessor :action + + # The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. + attr_accessor :metadata + + # The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. + attr_accessor :hierarchy + + # Promotion unique ID. + attr_accessor :promotion_id + + attr_accessor :campaign + + # Promotion tier's parent campaign's unique ID. + attr_accessor :campaign_id + + # A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier + attr_accessor :active + + # Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. + attr_accessor :start_date + + # Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + attr_accessor :summary + + # The type of object represented by JSON. This object stores information about the promotion tier. + attr_accessor :object + + attr_accessor :validation_rule_assignments + + # Promotion tier category ID. + attr_accessor :category_id + + attr_accessor :categories + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'name' => :'name', + :'banner' => :'banner', + :'action' => :'action', + :'metadata' => :'metadata', + :'hierarchy' => :'hierarchy', + :'promotion_id' => :'promotion_id', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'active' => :'active', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'summary' => :'summary', + :'object' => :'object', + :'validation_rule_assignments' => :'validation_rule_assignments', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'name' => :'String', + :'banner' => :'String', + :'action' => :'PromotionTierAction', + :'metadata' => :'Object', + :'hierarchy' => :'Integer', + :'promotion_id' => :'String', + :'campaign' => :'PromotionTierCampaign', + :'campaign_id' => :'String', + :'active' => :'Boolean', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'PromotionTierValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'summary' => :'PromotionTierSummary', + :'object' => :'String', + :'validation_rule_assignments' => :'ValidationRuleAssignmentsList', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTier` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + end + + if attributes.key?(:'promotion_id') + self.promotion_id = attributes[:'promotion_id'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_tier' + end + + if attributes.key?(:'validation_rule_assignments') + self.validation_rule_assignments = attributes[:'validation_rule_assignments'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + name == o.name && + banner == o.banner && + action == o.action && + metadata == o.metadata && + hierarchy == o.hierarchy && + promotion_id == o.promotion_id && + campaign == o.campaign && + campaign_id == o.campaign_id && + active == o.active && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + summary == o.summary && + object == o.object && + validation_rule_assignments == o.validation_rule_assignments && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, updated_at, name, banner, action, metadata, hierarchy, promotion_id, campaign, campaign_id, active, start_date, expiration_date, validity_timeframe, validity_day_of_week, summary, object, validation_rule_assignments, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_action.rb b/lib/VoucherifySdk/models/promotion_tier_action.rb new file mode 100644 index 00000000..98f766e9 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_action.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains details about the discount applied by the promotion tier. + class PromotionTierAction + attr_accessor :discount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'discount' => :'discount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'discount' => :'Discount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierAction` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierAction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + discount == o.discount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [discount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_campaign.rb b/lib/VoucherifySdk/models/promotion_tier_campaign.rb new file mode 100644 index 00000000..84e6c6e0 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_campaign.rb @@ -0,0 +1,289 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains details about promotion tier's parent campaign. + class PromotionTierCampaign + # Unique campaign ID. + attr_accessor :id + + # Activation timestamp defines when the campaign starts to be active in ISO 8601 format. Campaign is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the campaign expires in ISO 8601 format. Campaign is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the campaign is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # A flag indicating whether the campaign is active or not active. A campaign can be disabled even though it's within the active period defined by the `start_date` and `expiration_date` using the [Disable Campaign](ref:disable-campaign) endpoint. - `true` indicates an *active* campaign - `false` indicates an *inactive* campaign + attr_accessor :active + + # Unique category ID that this campaign belongs to. + attr_accessor :category_id + + # The type of object represented by the campaign object. This object stores information about the campaign. + attr_accessor :object + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'active' => :'active', + :'category_id' => :'category_id', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'PromotionTierCampaignValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'active' => :'Boolean', + :'category_id' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'campaign' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + active == o.active && + category_id == o.category_id && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, start_date, expiration_date, validity_timeframe, validity_day_of_week, active, category_id, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_campaign_validity_timeframe.rb b/lib/VoucherifySdk/models/promotion_tier_campaign_validity_timeframe.rb new file mode 100644 index 00000000..4946a705 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_campaign_validity_timeframe.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Recurrent time periods when the campaign is valid. For example, valid for 1 hour every other day. + class PromotionTierCampaignValidityTimeframe + # Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a campaign with an `interval` of `P2D` will be active every other day. + attr_accessor :interval + + # Defines the amount of time the campaign will be active in ISO 8601 format. For example, a campaign with a `duration` of `P1D` will be valid for a duration of one day. + attr_accessor :duration + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'interval' => :'interval', + :'duration' => :'duration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'interval' => :'String', + :'duration' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierCampaignValidityTimeframe` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierCampaignValidityTimeframe`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'interval') + self.interval = attributes[:'interval'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + interval == o.interval && + duration == o.duration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [interval, duration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_create_params.rb b/lib/VoucherifySdk/models/promotion_tier_create_params.rb new file mode 100644 index 00000000..52e2aa7c --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_create_params.rb @@ -0,0 +1,345 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a promotion tier create params. Promotion tiers are always assigned to a campaign and cannot be used standalone. + class PromotionTierCreateParams + # Name of the promotion tier. + attr_accessor :name + + # Text to be displayed to your customers on your website. + attr_accessor :banner + + attr_accessor :action + + # The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. + attr_accessor :metadata + + # Array containing the ID of the validation rule associated with the promotion tier. + attr_accessor :validation_rules + + # A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier + attr_accessor :active + + # The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. + attr_accessor :hierarchy + + # Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. + attr_accessor :start_date + + # Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # Assign category to the promotion tier. + attr_accessor :category + + # Instead of using the category name, you can alternatively assign a new category to a promotion tier using a unique category ID, i.e. `cat_0c9da30e7116ba6bba`. + attr_accessor :category_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'banner' => :'banner', + :'action' => :'action', + :'metadata' => :'metadata', + :'validation_rules' => :'validation_rules', + :'active' => :'active', + :'hierarchy' => :'hierarchy', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'category' => :'category', + :'category_id' => :'category_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'banner' => :'String', + :'action' => :'PromotionTierAction', + :'metadata' => :'Object', + :'validation_rules' => :'Array', + :'active' => :'Boolean', + :'hierarchy' => :'Integer', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'PromotionTierValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'category' => :'String', + :'category_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierCreateParams` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierCreateParams`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + banner == o.banner && + action == o.action && + metadata == o.metadata && + validation_rules == o.validation_rules && + active == o.active && + hierarchy == o.hierarchy && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + category == o.category && + category_id == o.category_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, banner, action, metadata, validation_rules, active, hierarchy, start_date, expiration_date, validity_timeframe, validity_day_of_week, category, category_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_summary.rb b/lib/VoucherifySdk/models/promotion_tier_summary.rb new file mode 100644 index 00000000..e6f77b72 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_summary.rb @@ -0,0 +1,224 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains statistics about promotion tier redemptions and orders. + class PromotionTierSummary + attr_accessor :redemptions + + attr_accessor :orders + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redemptions' => :'redemptions', + :'orders' => :'orders' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redemptions' => :'PromotionTierSummaryRedemptions', + :'orders' => :'PromotionTierSummaryOrders' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierSummary` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierSummary`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redemptions') + self.redemptions = attributes[:'redemptions'] + end + + if attributes.key?(:'orders') + self.orders = attributes[:'orders'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redemptions == o.redemptions && + orders == o.orders + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redemptions, orders].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_summary_orders.rb b/lib/VoucherifySdk/models/promotion_tier_summary_orders.rb new file mode 100644 index 00000000..b379d078 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_summary_orders.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains statistics about orders related to the promotion tier. + class PromotionTierSummaryOrders + # Sum of order totals. + attr_accessor :total_amount + + # Sum of total discount applied using the promotion tier. + attr_accessor :total_discount_amount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total_amount' => :'total_amount', + :'total_discount_amount' => :'total_discount_amount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total_amount' => :'Integer', + :'total_discount_amount' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierSummaryOrders` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierSummaryOrders`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_amount == o.total_amount && + total_discount_amount == o.total_discount_amount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total_amount, total_discount_amount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_summary_redemptions.rb b/lib/VoucherifySdk/models/promotion_tier_summary_redemptions.rb new file mode 100644 index 00000000..918e3b3f --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_summary_redemptions.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains statistics about promotion tier redemptions. + class PromotionTierSummaryRedemptions + # Number of times the promotion tier was redeemed. + attr_accessor :total_redeemed + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total_redeemed' => :'total_redeemed' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total_redeemed' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierSummaryRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierSummaryRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total_redeemed') + self.total_redeemed = attributes[:'total_redeemed'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_redeemed == o.total_redeemed + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total_redeemed].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tier_validity_timeframe.rb b/lib/VoucherifySdk/models/promotion_tier_validity_timeframe.rb new file mode 100644 index 00000000..759b9077 --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tier_validity_timeframe.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Set recurrent time periods when the promotion tier is valid. For example, valid for 1 hour every other day.`start_date` **required** when including the `validity_timeframe`. + class PromotionTierValidityTimeframe + # Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a promotion tier with an `interval` of `P2D` will be active every other day. + attr_accessor :interval + + # Defines the amount of time the promotion tier will be active in ISO 8601 format. For example, a promotion tier with a `duration` of `P1D` will be valid for a duration of one day. + attr_accessor :duration + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'interval' => :'interval', + :'duration' => :'duration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'interval' => :'String', + :'duration' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTierValidityTimeframe` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTierValidityTimeframe`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'interval') + self.interval = attributes[:'interval'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + interval == o.interval && + duration == o.duration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [interval, duration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotion_tiers_list.rb b/lib/VoucherifySdk/models/promotion_tiers_list.rb new file mode 100644 index 00000000..8ec34e6f --- /dev/null +++ b/lib/VoucherifySdk/models/promotion_tiers_list.rb @@ -0,0 +1,262 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Promotion Tiers + class PromotionTiersList + # The type of object represented by JSON. This object stores information about promotion tiers in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of promotion tier objects. + attr_accessor :data_ref + + # Contains array of promotion tier objects. + attr_accessor :tiers + + # Total number of promotion tiers. + attr_accessor :total + + # As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. + attr_accessor :has_more + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'tiers' => :'tiers', + :'total' => :'total', + :'has_more' => :'has_more' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'tiers' => :'Array', + :'total' => :'Integer', + :'has_more' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionTiersList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionTiersList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'tiers' + end + + if attributes.key?(:'tiers') + if (value = attributes[:'tiers']).is_a?(Array) + self.tiers = value + end + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + tiers == o.tiers && + total == o.total && + has_more == o.has_more + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, tiers, total, has_more].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_stacks_create_request_body.rb b/lib/VoucherifySdk/models/promotions_stacks_create_request_body.rb new file mode 100644 index 00000000..f9d2baa8 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_stacks_create_request_body.rb @@ -0,0 +1,256 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/promotions/{campaignId}/stacks`. + class PromotionsStacksCreateRequestBody + # Promotion stack name. + attr_accessor :name + + attr_accessor :tiers + + # Promotion stack category ID. + attr_accessor :category_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'tiers' => :'tiers', + :'category_id' => :'category_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'tiers' => :'PromotionStackBaseTiers', + :'category_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionStackBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsStacksCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsStacksCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'tiers') + self.tiers = attributes[:'tiers'] + else + self.tiers = nil + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @tiers.nil? + invalid_properties.push('invalid value for "tiers", tiers cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @tiers.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + tiers == o.tiers && + category_id == o.category_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, tiers, category_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_stacks_create_response_body.rb b/lib/VoucherifySdk/models/promotions_stacks_create_response_body.rb new file mode 100644 index 00000000..14cdf277 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_stacks_create_response_body.rb @@ -0,0 +1,380 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/promotions/{campaignId}/stacks`. + class PromotionsStacksCreateResponseBody + # Promotion stack name. + attr_accessor :name + + attr_accessor :tiers + + # Unique promotion stack ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. + attr_accessor :created_at + + # Promotion stack's parent campaign's unique ID. + attr_accessor :campaign_id + + # The type of object represented by JSON. + attr_accessor :object + + # Promotion stack category ID. + attr_accessor :category_id + + # Details about the category assigned to the promotion stack. + attr_accessor :categories + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'tiers' => :'tiers', + :'id' => :'id', + :'created_at' => :'created_at', + :'campaign_id' => :'campaign_id', + :'object' => :'object', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'tiers' => :'PromotionStackBaseTiers', + :'id' => :'String', + :'created_at' => :'Time', + :'campaign_id' => :'String', + :'object' => :'String', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionStackBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsStacksCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsStacksCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'tiers') + self.tiers = attributes[:'tiers'] + else + self.tiers = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_stack' + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @tiers.nil? + invalid_properties.push('invalid value for "tiers", tiers cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @tiers.nil? + return false if @id.nil? + return false if @created_at.nil? + return false if @campaign_id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + return false unless object_validator.valid?(@object) + return false if @categories.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + tiers == o.tiers && + id == o.id && + created_at == o.created_at && + campaign_id == o.campaign_id && + object == o.object && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, tiers, id, created_at, campaign_id, object, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_stacks_get_response_body.rb b/lib/VoucherifySdk/models/promotions_stacks_get_response_body.rb new file mode 100644 index 00000000..ec5ec3bd --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_stacks_get_response_body.rb @@ -0,0 +1,390 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/promotions/{campaignId}/stacks/{stackId}`. + class PromotionsStacksGetResponseBody + # Promotion stack name. + attr_accessor :name + + attr_accessor :tiers + + # Unique promotion stack ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the promotion stack was updated in ISO 8601 format. + attr_accessor :updated_at + + # Promotion stack's parent campaign's unique ID. + attr_accessor :campaign_id + + # The type of object represented by JSON. + attr_accessor :object + + # Promotion stack category ID. + attr_accessor :category_id + + # Details about the category assigned to the promotion stack. + attr_accessor :categories + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'tiers' => :'tiers', + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'campaign_id' => :'campaign_id', + :'object' => :'object', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'tiers' => :'PromotionStackBaseTiers', + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'campaign_id' => :'String', + :'object' => :'String', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionStack' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsStacksGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsStacksGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'tiers') + self.tiers = attributes[:'tiers'] + else + self.tiers = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_stack' + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @tiers.nil? + invalid_properties.push('invalid value for "tiers", tiers cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @tiers.nil? + return false if @id.nil? + return false if @created_at.nil? + return false if @campaign_id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + return false unless object_validator.valid?(@object) + return false if @categories.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + tiers == o.tiers && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + campaign_id == o.campaign_id && + object == o.object && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, tiers, id, created_at, updated_at, campaign_id, object, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_stacks_list_response_body.rb b/lib/VoucherifySdk/models/promotions_stacks_list_response_body.rb new file mode 100644 index 00000000..8c490083 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_stacks_list_response_body.rb @@ -0,0 +1,341 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/promotions/stacks` and for **GET** `/promotions/{campaignId}/stacks`. + class PromotionsStacksListResponseBody + # The type of object represented by JSON. This object stores information about promotion stacks in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of promotion stack objects. + attr_accessor :data_ref + + # Contains array of promotion stack objects. + attr_accessor :data + + # Total number of promotion stacks. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsStacksListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsStacksListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @total < 0 + invalid_properties.push('invalid value for "total", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + return false if @total < 0 + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Custom attribute writer method with validation + # @param [Object] total Value to be assigned + def total=(total) + if total.nil? + fail ArgumentError, 'total cannot be nil' + end + + if total < 0 + fail ArgumentError, 'invalid value for "total", must be greater than or equal to 0.' + end + + @total = total + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_stacks_update_request_body.rb b/lib/VoucherifySdk/models/promotions_stacks_update_request_body.rb new file mode 100644 index 00000000..0678b825 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_stacks_update_request_body.rb @@ -0,0 +1,235 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request Body schema for **put** `/promotions/{campaignId}/stacks/{stackId}`. + class PromotionsStacksUpdateRequestBody + # Promotion stack name. + attr_accessor :name + + attr_accessor :tiers + + # Promotion stack category ID. + attr_accessor :category_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'tiers' => :'tiers', + :'category_id' => :'category_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'tiers' => :'PromotionsStacksUpdateRequestBodyTiers', + :'category_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsStacksUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsStacksUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'tiers') + self.tiers = attributes[:'tiers'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + tiers == o.tiers && + category_id == o.category_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, tiers, category_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_stacks_update_request_body_tiers.rb b/lib/VoucherifySdk/models/promotions_stacks_update_request_body_tiers.rb new file mode 100644 index 00000000..24c9e6f4 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_stacks_update_request_body_tiers.rb @@ -0,0 +1,264 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the tier configuration. + class PromotionsStacksUpdateRequestBodyTiers + # Contains the list of tiers in a pre-defined sequence. + attr_accessor :ids + + # Category hierarchy. + attr_accessor :hierarchy_mode + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'ids' => :'ids', + :'hierarchy_mode' => :'hierarchy_mode' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'ids' => :'Array', + :'hierarchy_mode' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsStacksUpdateRequestBodyTiers` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsStacksUpdateRequestBodyTiers`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'ids') + if (value = attributes[:'ids']).is_a?(Array) + self.ids = value + end + end + + if attributes.key?(:'hierarchy_mode') + self.hierarchy_mode = attributes[:'hierarchy_mode'] + else + self.hierarchy_mode = 'MANUAL' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + hierarchy_mode_validator = EnumAttributeValidator.new('String', ["MANUAL"]) + return false unless hierarchy_mode_validator.valid?(@hierarchy_mode) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] hierarchy_mode Object to be assigned + def hierarchy_mode=(hierarchy_mode) + validator = EnumAttributeValidator.new('String', ["MANUAL"]) + unless validator.valid?(hierarchy_mode) + fail ArgumentError, "invalid value for \"hierarchy_mode\", must be one of #{validator.allowable_values}." + end + @hierarchy_mode = hierarchy_mode + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + ids == o.ids && + hierarchy_mode == o.hierarchy_mode + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [ids, hierarchy_mode].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_stacks_update_response_body.rb b/lib/VoucherifySdk/models/promotions_stacks_update_response_body.rb new file mode 100644 index 00000000..0ee50ded --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_stacks_update_response_body.rb @@ -0,0 +1,397 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/promotions/{campaignId}/stacks/{stackId}`. + class PromotionsStacksUpdateResponseBody + # Promotion stack name. + attr_accessor :name + + attr_accessor :tiers + + # Unique promotion stack ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion stack was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the promotion stack was updated in ISO 8601 format. + attr_accessor :updated_at + + # Promotion stack's parent campaign's unique ID. + attr_accessor :campaign_id + + # The type of object represented by JSON. + attr_accessor :object + + # Promotion stack category ID. + attr_accessor :category_id + + # Details about the category assigned to the promotion stack. + attr_accessor :categories + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'tiers' => :'tiers', + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'campaign_id' => :'campaign_id', + :'object' => :'object', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'tiers' => :'PromotionStackBaseTiers', + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'campaign_id' => :'String', + :'object' => :'String', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'category_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionStackBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsStacksUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsStacksUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'tiers') + self.tiers = attributes[:'tiers'] + else + self.tiers = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_stack' + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + else + self.category_id = nil + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + else + self.categories = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @tiers.nil? + invalid_properties.push('invalid value for "tiers", tiers cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @updated_at.nil? + invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @categories.nil? + invalid_properties.push('invalid value for "categories", categories cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @tiers.nil? + return false if @id.nil? + return false if @created_at.nil? + return false if @updated_at.nil? + return false if @campaign_id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + return false unless object_validator.valid?(@object) + return false if @categories.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + tiers == o.tiers && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + campaign_id == o.campaign_id && + object == o.object && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, tiers, id, created_at, updated_at, campaign_id, object, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_tiers_disable_response_body.rb b/lib/VoucherifySdk/models/promotions_tiers_disable_response_body.rb new file mode 100644 index 00000000..0240274b --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_tiers_disable_response_body.rb @@ -0,0 +1,423 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/promotions/tiers/{promotionTierId}/disable`. + class PromotionsTiersDisableResponseBody + # Unique promotion tier ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. + attr_accessor :updated_at + + # Name of the promotion tier. + attr_accessor :name + + # Text to be displayed to your customers on your website. + attr_accessor :banner + + attr_accessor :action + + # The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. + attr_accessor :metadata + + # The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. + attr_accessor :hierarchy + + # Promotion unique ID. + attr_accessor :promotion_id + + attr_accessor :campaign + + # Promotion tier's parent campaign's unique ID. + attr_accessor :campaign_id + + # A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier + attr_accessor :active + + # Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. + attr_accessor :start_date + + # Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + attr_accessor :summary + + # The type of object represented by JSON. This object stores information about the promotion tier. + attr_accessor :object + + attr_accessor :validation_rule_assignments + + # Promotion tier category ID. + attr_accessor :category_id + + attr_accessor :categories + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'name' => :'name', + :'banner' => :'banner', + :'action' => :'action', + :'metadata' => :'metadata', + :'hierarchy' => :'hierarchy', + :'promotion_id' => :'promotion_id', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'active' => :'active', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'summary' => :'summary', + :'object' => :'object', + :'validation_rule_assignments' => :'validation_rule_assignments', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'name' => :'String', + :'banner' => :'String', + :'action' => :'PromotionTierAction', + :'metadata' => :'Object', + :'hierarchy' => :'Integer', + :'promotion_id' => :'String', + :'campaign' => :'PromotionTierCampaign', + :'campaign_id' => :'String', + :'active' => :'Boolean', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'PromotionTierValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'summary' => :'PromotionTierSummary', + :'object' => :'String', + :'validation_rule_assignments' => :'ValidationRuleAssignmentsList', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionTier' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsTiersDisableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsTiersDisableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + end + + if attributes.key?(:'promotion_id') + self.promotion_id = attributes[:'promotion_id'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_tier' + end + + if attributes.key?(:'validation_rule_assignments') + self.validation_rule_assignments = attributes[:'validation_rule_assignments'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + name == o.name && + banner == o.banner && + action == o.action && + metadata == o.metadata && + hierarchy == o.hierarchy && + promotion_id == o.promotion_id && + campaign == o.campaign && + campaign_id == o.campaign_id && + active == o.active && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + summary == o.summary && + object == o.object && + validation_rule_assignments == o.validation_rule_assignments && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, updated_at, name, banner, action, metadata, hierarchy, promotion_id, campaign, campaign_id, active, start_date, expiration_date, validity_timeframe, validity_day_of_week, summary, object, validation_rule_assignments, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_tiers_enable_response_body.rb b/lib/VoucherifySdk/models/promotions_tiers_enable_response_body.rb new file mode 100644 index 00000000..512ac1d1 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_tiers_enable_response_body.rb @@ -0,0 +1,423 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/promotions/tiers/{promotionTierId}/enable`. + class PromotionsTiersEnableResponseBody + # Unique promotion tier ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. + attr_accessor :updated_at + + # Name of the promotion tier. + attr_accessor :name + + # Text to be displayed to your customers on your website. + attr_accessor :banner + + attr_accessor :action + + # The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. + attr_accessor :metadata + + # The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. + attr_accessor :hierarchy + + # Promotion unique ID. + attr_accessor :promotion_id + + attr_accessor :campaign + + # Promotion tier's parent campaign's unique ID. + attr_accessor :campaign_id + + # A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier + attr_accessor :active + + # Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. + attr_accessor :start_date + + # Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + attr_accessor :summary + + # The type of object represented by JSON. This object stores information about the promotion tier. + attr_accessor :object + + attr_accessor :validation_rule_assignments + + # Promotion tier category ID. + attr_accessor :category_id + + attr_accessor :categories + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'name' => :'name', + :'banner' => :'banner', + :'action' => :'action', + :'metadata' => :'metadata', + :'hierarchy' => :'hierarchy', + :'promotion_id' => :'promotion_id', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'active' => :'active', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'summary' => :'summary', + :'object' => :'object', + :'validation_rule_assignments' => :'validation_rule_assignments', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'name' => :'String', + :'banner' => :'String', + :'action' => :'PromotionTierAction', + :'metadata' => :'Object', + :'hierarchy' => :'Integer', + :'promotion_id' => :'String', + :'campaign' => :'PromotionTierCampaign', + :'campaign_id' => :'String', + :'active' => :'Boolean', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'PromotionTierValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'summary' => :'PromotionTierSummary', + :'object' => :'String', + :'validation_rule_assignments' => :'ValidationRuleAssignmentsList', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionTier' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsTiersEnableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsTiersEnableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + end + + if attributes.key?(:'promotion_id') + self.promotion_id = attributes[:'promotion_id'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_tier' + end + + if attributes.key?(:'validation_rule_assignments') + self.validation_rule_assignments = attributes[:'validation_rule_assignments'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + name == o.name && + banner == o.banner && + action == o.action && + metadata == o.metadata && + hierarchy == o.hierarchy && + promotion_id == o.promotion_id && + campaign == o.campaign && + campaign_id == o.campaign_id && + active == o.active && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + summary == o.summary && + object == o.object && + validation_rule_assignments == o.validation_rule_assignments && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, updated_at, name, banner, action, metadata, hierarchy, promotion_id, campaign, campaign_id, active, start_date, expiration_date, validity_timeframe, validity_day_of_week, summary, object, validation_rule_assignments, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_tiers_get_response_body.rb b/lib/VoucherifySdk/models/promotions_tiers_get_response_body.rb new file mode 100644 index 00000000..2fd138f3 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_tiers_get_response_body.rb @@ -0,0 +1,423 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/promotions/tiers/{promotionTierId}`. + class PromotionsTiersGetResponseBody + # Unique promotion tier ID. + attr_accessor :id + + # Timestamp representing the date and time when the promotion tier was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the promotion tier was updated in ISO 8601 format. + attr_accessor :updated_at + + # Name of the promotion tier. + attr_accessor :name + + # Text to be displayed to your customers on your website. + attr_accessor :banner + + attr_accessor :action + + # The metadata object stores all custom attributes assigned to the promotion tier. A set of key/value pairs that you can attach to a promotion tier object. It can be useful for storing additional information about the promotion tier in a structured format. + attr_accessor :metadata + + # The promotions hierarchy defines the order in which the discounts from different tiers will be applied to a customer's order. If a customer qualifies for discounts from more than one tier, discounts will be applied in the order defined in the hierarchy. + attr_accessor :hierarchy + + # Promotion unique ID. + attr_accessor :promotion_id + + attr_accessor :campaign + + # Promotion tier's parent campaign's unique ID. + attr_accessor :campaign_id + + # A flag to toggle the promotion tier on or off. You can disable a promotion tier even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* promotion tier - `false` indicates an *inactive* promotion tier + attr_accessor :active + + # Activation timestamp defines when the promotion tier starts to be active in ISO 8601 format. Promotion tier is *inactive before* this date. + attr_accessor :start_date + + # Activation timestamp defines when the promotion tier expires in ISO 8601 format. Promotion tier is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the promotion tier is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + attr_accessor :summary + + # The type of object represented by JSON. This object stores information about the promotion tier. + attr_accessor :object + + attr_accessor :validation_rule_assignments + + # Promotion tier category ID. + attr_accessor :category_id + + attr_accessor :categories + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'name' => :'name', + :'banner' => :'banner', + :'action' => :'action', + :'metadata' => :'metadata', + :'hierarchy' => :'hierarchy', + :'promotion_id' => :'promotion_id', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'active' => :'active', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'summary' => :'summary', + :'object' => :'object', + :'validation_rule_assignments' => :'validation_rule_assignments', + :'category_id' => :'category_id', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'name' => :'String', + :'banner' => :'String', + :'action' => :'PromotionTierAction', + :'metadata' => :'Object', + :'hierarchy' => :'Integer', + :'promotion_id' => :'String', + :'campaign' => :'PromotionTierCampaign', + :'campaign_id' => :'String', + :'active' => :'Boolean', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'PromotionTierValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'summary' => :'PromotionTierSummary', + :'object' => :'String', + :'validation_rule_assignments' => :'ValidationRuleAssignmentsList', + :'category_id' => :'String', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionTier' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsTiersGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsTiersGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'hierarchy') + self.hierarchy = attributes[:'hierarchy'] + end + + if attributes.key?(:'promotion_id') + self.promotion_id = attributes[:'promotion_id'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_tier' + end + + if attributes.key?(:'validation_rule_assignments') + self.validation_rule_assignments = attributes[:'validation_rule_assignments'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + name == o.name && + banner == o.banner && + action == o.action && + metadata == o.metadata && + hierarchy == o.hierarchy && + promotion_id == o.promotion_id && + campaign == o.campaign && + campaign_id == o.campaign_id && + active == o.active && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + summary == o.summary && + object == o.object && + validation_rule_assignments == o.validation_rule_assignments && + category_id == o.category_id && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, created_at, updated_at, name, banner, action, metadata, hierarchy, promotion_id, campaign, campaign_id, active, start_date, expiration_date, validity_timeframe, validity_day_of_week, summary, object, validation_rule_assignments, category_id, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/promotions_tiers_list_response_body.rb b/lib/VoucherifySdk/models/promotions_tiers_list_response_body.rb new file mode 100644 index 00000000..f4d2b095 --- /dev/null +++ b/lib/VoucherifySdk/models/promotions_tiers_list_response_body.rb @@ -0,0 +1,269 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/promotions/{campaignId}/tiers`. + class PromotionsTiersListResponseBody + # The type of object represented by JSON. This object stores information about promotion tiers in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of promotion tier objects. + attr_accessor :data_ref + + # Contains array of promotion tier objects. + attr_accessor :tiers + + # Total number of promotion tiers. + attr_accessor :total + + # As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. + attr_accessor :has_more + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'tiers' => :'tiers', + :'total' => :'total', + :'has_more' => :'has_more' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'tiers' => :'Array', + :'total' => :'Integer', + :'has_more' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PromotionTiersList' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PromotionsTiersListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PromotionsTiersListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'tiers' + end + + if attributes.key?(:'tiers') + if (value = attributes[:'tiers']).is_a?(Array) + self.tiers = value + end + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + tiers == o.tiers && + total == o.total && + has_more == o.has_more + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, tiers, total, has_more].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/properties_for_loyalty_campaign_options.rb b/lib/VoucherifySdk/models/properties_for_loyalty_campaign_options.rb new file mode 100644 index 00000000..3671314c --- /dev/null +++ b/lib/VoucherifySdk/models/properties_for_loyalty_campaign_options.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class PropertiesForLoyaltyCampaignOptions + # Determine if tiers should be recalculated or no. + attr_accessor :recalculate_tiers + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'recalculate_tiers' => :'recalculate_tiers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'recalculate_tiers' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PropertiesForLoyaltyCampaignOptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PropertiesForLoyaltyCampaignOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'recalculate_tiers') + self.recalculate_tiers = attributes[:'recalculate_tiers'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + recalculate_tiers == o.recalculate_tiers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [recalculate_tiers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/publications_create_base_response_body.rb b/lib/VoucherifySdk/models/publications_create_base_response_body.rb new file mode 100644 index 00000000..62f609bd --- /dev/null +++ b/lib/VoucherifySdk/models/publications_create_base_response_body.rb @@ -0,0 +1,440 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class PublicationsCreateBaseResponseBody + # Unique publication ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `publication`. + attr_accessor :object + + # Timestamp representing the date and time when the publication was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer receiving the publication. + attr_accessor :customer_id + + # Customer's `source_id`. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # How the publication was originated. It can be your own custom channel or an example value provided here. + attr_accessor :channel + + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + # Status of the publication attempt. + attr_accessor :result + + attr_accessor :customer + + # Contains the unique internal voucher ID that was assigned by Voucherify. + attr_accessor :vouchers_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel' => :'channel', + :'source_id' => :'source_id', + :'result' => :'result', + :'customer' => :'customer', + :'vouchers_id' => :'vouchers_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel' => :'String', + :'source_id' => :'String', + :'result' => :'String', + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'vouchers_id' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PublicationsCreateBaseResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PublicationsCreateBaseResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'publication' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = 'API' + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = 'SUCCESS' + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'vouchers_id') + if (value = attributes[:'vouchers_id']).is_a?(Array) + self.vouchers_id = value + end + else + self.vouchers_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @vouchers_id.nil? + invalid_properties.push('invalid value for "vouchers_id", vouchers_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @customer_id.nil? + return false if @metadata.nil? + return false if @channel.nil? + channel_validator = EnumAttributeValidator.new('String', ["API"]) + return false unless channel_validator.valid?(@channel) + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + return false unless result_validator.valid?(@result) + return false if @customer.nil? + return false if @vouchers_id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel Object to be assigned + def channel=(channel) + validator = EnumAttributeValidator.new('String', ["API"]) + unless validator.valid?(channel) + fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}." + end + @channel = channel + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel == o.channel && + source_id == o.source_id && + result == o.result && + customer == o.customer && + vouchers_id == o.vouchers_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, customer_id, tracking_id, metadata, channel, source_id, result, customer, vouchers_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/publications_create_request_body.rb b/lib/VoucherifySdk/models/publications_create_request_body.rb new file mode 100644 index 00000000..c9adead7 --- /dev/null +++ b/lib/VoucherifySdk/models/publications_create_request_body.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/publications`. + module PublicationsCreateRequestBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'CreatePublicationWithCampaign', + :'CreatePublicationWithSpecificVoucher' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/publications_create_response_body.rb b/lib/VoucherifySdk/models/publications_create_response_body.rb new file mode 100644 index 00000000..af3089d1 --- /dev/null +++ b/lib/VoucherifySdk/models/publications_create_response_body.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/publication` and **GET** `/publications/create`. + module PublicationsCreateResponseBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'PublicationsCreateVoucherResponseBody', + :'PublicationsCreateVouchersResponseBody' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/publications_create_voucher_response_body.rb b/lib/VoucherifySdk/models/publications_create_voucher_response_body.rb new file mode 100644 index 00000000..a7b3d14e --- /dev/null +++ b/lib/VoucherifySdk/models/publications_create_voucher_response_body.rb @@ -0,0 +1,464 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/publication` and **GET** `/publications/create`. + class PublicationsCreateVoucherResponseBody + # Unique publication ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `publication`. + attr_accessor :object + + # Timestamp representing the date and time when the publication was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer receiving the publication. + attr_accessor :customer_id + + # Customer's `source_id`. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # How the publication was originated. It can be your own custom channel or an example value provided here. + attr_accessor :channel + + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + # Status of the publication attempt. + attr_accessor :result + + attr_accessor :customer + + # Contains the unique internal voucher ID that was assigned by Voucherify. + attr_accessor :vouchers_id + + attr_accessor :voucher + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel' => :'channel', + :'source_id' => :'source_id', + :'result' => :'result', + :'customer' => :'customer', + :'vouchers_id' => :'vouchers_id', + :'voucher' => :'voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel' => :'String', + :'source_id' => :'String', + :'result' => :'String', + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'vouchers_id' => :'Array', + :'voucher' => :'Voucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PublicationsCreateBaseResponseBody' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PublicationsCreateVoucherResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PublicationsCreateVoucherResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'publication' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = 'API' + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = 'SUCCESS' + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'vouchers_id') + if (value = attributes[:'vouchers_id']).is_a?(Array) + self.vouchers_id = value + end + else + self.vouchers_id = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + else + self.voucher = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @vouchers_id.nil? + invalid_properties.push('invalid value for "vouchers_id", vouchers_id cannot be nil.') + end + + if @voucher.nil? + invalid_properties.push('invalid value for "voucher", voucher cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @customer_id.nil? + return false if @metadata.nil? + return false if @channel.nil? + channel_validator = EnumAttributeValidator.new('String', ["API"]) + return false unless channel_validator.valid?(@channel) + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + return false unless result_validator.valid?(@result) + return false if @customer.nil? + return false if @vouchers_id.nil? + return false if @voucher.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel Object to be assigned + def channel=(channel) + validator = EnumAttributeValidator.new('String', ["API"]) + unless validator.valid?(channel) + fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}." + end + @channel = channel + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel == o.channel && + source_id == o.source_id && + result == o.result && + customer == o.customer && + vouchers_id == o.vouchers_id && + voucher == o.voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, customer_id, tracking_id, metadata, channel, source_id, result, customer, vouchers_id, voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/publications_create_vouchers_response_body.rb b/lib/VoucherifySdk/models/publications_create_vouchers_response_body.rb new file mode 100644 index 00000000..2cd7a971 --- /dev/null +++ b/lib/VoucherifySdk/models/publications_create_vouchers_response_body.rb @@ -0,0 +1,467 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/publication` and **GET** `/publications/create`. + class PublicationsCreateVouchersResponseBody + # Unique publication ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `publication`. + attr_accessor :object + + # Timestamp representing the date and time when the publication was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer receiving the publication. + attr_accessor :customer_id + + # Customer's `source_id`. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format. + attr_accessor :metadata + + # How the publication was originated. It can be your own custom channel or an example value provided here. + attr_accessor :channel + + # The merchant’s publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + # Status of the publication attempt. + attr_accessor :result + + attr_accessor :customer + + # Contains the unique internal voucher ID that was assigned by Voucherify. + attr_accessor :vouchers_id + + # Contains the unique voucher codes that was assigned by Voucherify. + attr_accessor :vouchers + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel' => :'channel', + :'source_id' => :'source_id', + :'result' => :'result', + :'customer' => :'customer', + :'vouchers_id' => :'vouchers_id', + :'vouchers' => :'vouchers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel' => :'String', + :'source_id' => :'String', + :'result' => :'String', + :'customer' => :'CustomerWithSummaryLoyaltyReferrals', + :'vouchers_id' => :'Array', + :'vouchers' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'PublicationsCreateBaseResponseBody' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PublicationsCreateVouchersResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PublicationsCreateVouchersResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'publication' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = 'API' + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = 'SUCCESS' + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'vouchers_id') + if (value = attributes[:'vouchers_id']).is_a?(Array) + self.vouchers_id = value + end + else + self.vouchers_id = nil + end + + if attributes.key?(:'vouchers') + if (value = attributes[:'vouchers']).is_a?(Array) + self.vouchers = value + end + else + self.vouchers = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @customer_id.nil? + invalid_properties.push('invalid value for "customer_id", customer_id cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @customer.nil? + invalid_properties.push('invalid value for "customer", customer cannot be nil.') + end + + if @vouchers_id.nil? + invalid_properties.push('invalid value for "vouchers_id", vouchers_id cannot be nil.') + end + + if @vouchers.nil? + invalid_properties.push('invalid value for "vouchers", vouchers cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["publication"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @customer_id.nil? + return false if @metadata.nil? + return false if @channel.nil? + channel_validator = EnumAttributeValidator.new('String', ["API"]) + return false unless channel_validator.valid?(@channel) + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + return false unless result_validator.valid?(@result) + return false if @customer.nil? + return false if @vouchers_id.nil? + return false if @vouchers.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["publication"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel Object to be assigned + def channel=(channel) + validator = EnumAttributeValidator.new('String', ["API"]) + unless validator.valid?(channel) + fail ArgumentError, "invalid value for \"channel\", must be one of #{validator.allowable_values}." + end + @channel = channel + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel == o.channel && + source_id == o.source_id && + result == o.result && + customer == o.customer && + vouchers_id == o.vouchers_id && + vouchers == o.vouchers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, customer_id, tracking_id, metadata, channel, source_id, result, customer, vouchers_id, vouchers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/publications_list_response_body.rb b/lib/VoucherifySdk/models/publications_list_response_body.rb new file mode 100644 index 00000000..90277aac --- /dev/null +++ b/lib/VoucherifySdk/models/publications_list_response_body.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for listing publications using **GET** `/publications`. + class PublicationsListResponseBody + # The type of object represented by JSON. This object stores information about publications in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of publications. + attr_accessor :data_ref + + # Contains array of publication objects, voucher object will be simplified. + attr_accessor :publications + + # Total number of publications. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'publications' => :'publications', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'publications' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::PublicationsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::PublicationsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'publications' + end + + if attributes.key?(:'publications') + if (value = attributes[:'publications']).is_a?(Array) + self.publications = value + end + else + self.publications = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @publications.nil? + invalid_properties.push('invalid value for "publications", publications cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @publications.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + publications == o.publications && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, publications, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/publications_list_response_body_publications_item.rb b/lib/VoucherifySdk/models/publications_list_response_body_publications_item.rb new file mode 100644 index 00000000..20934125 --- /dev/null +++ b/lib/VoucherifySdk/models/publications_list_response_body_publications_item.rb @@ -0,0 +1,107 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response schema model for publishing vouchers to a specific customer. + module PublicationsListResponseBodyPublicationsItem + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ListPublicationsItemInvalid', + :'ListPublicationsItemValidMultipleVouchers', + :'ListPublicationsItemValidSingleVoucher' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_check_eligibility_request_body.rb b/lib/VoucherifySdk/models/qualifications_check_eligibility_request_body.rb new file mode 100644 index 00000000..917dfe37 --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_check_eligibility_request_body.rb @@ -0,0 +1,319 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/qualifications`. + class QualificationsCheckEligibilityRequestBody + attr_accessor :customer + + attr_accessor :order + + # Defines which resources Voucherify will use. The `ADVANCED` mode is available after purchase only. + attr_accessor :mode + + # Is correspondent to Customer's source_id + attr_accessor :tracking_id + + # Defines the scenario Voucherify should consider during the qualification process. - `ALL` - Scenario that returns all redeemables available for the customer in one API request. This scenario is used by default when no value is selected. - `CUSTOMER_WALLET` - returns vouchers applicable to the customer’s cart based on the vouchers assigned to the customer’s profile. - `AUDIENCE_ONLY` - returns all vouchers, promotion tiers, and campaigns available to the customer. Voucherify validates the rules based on the customer profile only. - `PRODUCTS` - returns all promotions available for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT` - returns all promotions available for products when a discount is defined as applicable to specific item(s). - `PROMOTION_STACKS` - returns the applicable promotion stacks. - `PRODUCTS_BY_CUSTOMER` - returns all promotions available for a customer for the products (when a discount is defined to be applied to the item or when the item is required in the validation rule). - `PRODUCTS_DISCOUNT_BY_CUSTOMER` - returns all promotions available for a customer for products when a discount is defined as applicable to specific item(s). + attr_accessor :scenario + + attr_accessor :options + + # A set of key/value pairs that you can send in the request body to check against redeemables requiring **redemption** metadata validation rules to be satisfied. The validation runs against rules that are defined through the [Create Validation Rules](ref:create-validation-rules) endpoint or via the Dashboard; in the _Advanced Rule Builder_ → _Advanced_ → _Redemption metadata satisfy_ or _Basic Builder_ → _Attributes match_ → _REDEMPTION METADATA_. [Read more](https://support.voucherify.io/article/148-how-to-build-a-rule). + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'order' => :'order', + :'mode' => :'mode', + :'tracking_id' => :'tracking_id', + :'scenario' => :'scenario', + :'options' => :'options', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'Customer', + :'order' => :'Order', + :'mode' => :'String', + :'tracking_id' => :'String', + :'scenario' => :'String', + :'options' => :'QualificationsOption', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsCheckEligibilityRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsCheckEligibilityRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'mode') + self.mode = attributes[:'mode'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'scenario') + self.scenario = attributes[:'scenario'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + mode_validator = EnumAttributeValidator.new('String', ["BASIC", "ADVANCED"]) + return false unless mode_validator.valid?(@mode) + scenario_validator = EnumAttributeValidator.new('String', ["ALL", "CUSTOMER_WALLET", "AUDIENCE_ONLY", "PRODUCTS", "PRODUCTS_DISCOUNT", "PROMOTION_STACKS", "PRODUCTS_BY_CUSTOMER", "PRODUCTS_DISCOUNT_BY_CUSTOMER"]) + return false unless scenario_validator.valid?(@scenario) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] mode Object to be assigned + def mode=(mode) + validator = EnumAttributeValidator.new('String', ["BASIC", "ADVANCED"]) + unless validator.valid?(mode) + fail ArgumentError, "invalid value for \"mode\", must be one of #{validator.allowable_values}." + end + @mode = mode + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] scenario Object to be assigned + def scenario=(scenario) + validator = EnumAttributeValidator.new('String', ["ALL", "CUSTOMER_WALLET", "AUDIENCE_ONLY", "PRODUCTS", "PRODUCTS_DISCOUNT", "PROMOTION_STACKS", "PRODUCTS_BY_CUSTOMER", "PRODUCTS_DISCOUNT_BY_CUSTOMER"]) + unless validator.valid?(scenario) + fail ArgumentError, "invalid value for \"scenario\", must be one of #{validator.allowable_values}." + end + @scenario = scenario + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + order == o.order && + mode == o.mode && + tracking_id == o.tracking_id && + scenario == o.scenario && + options == o.options && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, order, mode, tracking_id, scenario, options, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_check_eligibility_response_body.rb b/lib/VoucherifySdk/models/qualifications_check_eligibility_response_body.rb new file mode 100644 index 00000000..555244b0 --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_check_eligibility_response_body.rb @@ -0,0 +1,243 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/qualifications`. + class QualificationsCheckEligibilityResponseBody + attr_accessor :redeemables + + # This identifier is generated during voucher qualification based on your internal id (e.g., email, database ID). This is a hashed customer source ID. + attr_accessor :tracking_id + + attr_accessor :order + + attr_accessor :stacking_rules + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables' => :'redeemables', + :'tracking_id' => :'tracking_id', + :'order' => :'order', + :'stacking_rules' => :'stacking_rules' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables' => :'QualificationsRedeemables', + :'tracking_id' => :'String', + :'order' => :'OrderCalculated', + :'stacking_rules' => :'StackingRules' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsCheckEligibilityResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsCheckEligibilityResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables') + self.redeemables = attributes[:'redeemables'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'stacking_rules') + self.stacking_rules = attributes[:'stacking_rules'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables == o.redeemables && + tracking_id == o.tracking_id && + order == o.order && + stacking_rules == o.stacking_rules + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables, tracking_id, order, stacking_rules].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_field_conditions.rb b/lib/VoucherifySdk/models/qualifications_field_conditions.rb new file mode 100644 index 00000000..4e3634af --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_field_conditions.rb @@ -0,0 +1,214 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class QualificationsFieldConditions + attr_accessor :conditions + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'QualificationsFiltersCondition' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsFieldConditions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsFieldConditions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_filters_condition.rb b/lib/VoucherifySdk/models/qualifications_filters_condition.rb new file mode 100644 index 00000000..48d05040 --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_filters_condition.rb @@ -0,0 +1,259 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class QualificationsFiltersCondition + attr_accessor :is + + attr_accessor :is_not + + attr_accessor :has_value + + attr_accessor :is_unknown + + attr_accessor :_in + + attr_accessor :not_in + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'is' => :'$is', + :'is_not' => :'$is_not', + :'has_value' => :'$has_value', + :'is_unknown' => :'$is_unknown', + :'_in' => :'$in', + :'not_in' => :'$not_in' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'is' => :'Any', + :'is_not' => :'Any', + :'has_value' => :'Any', + :'is_unknown' => :'Any', + :'_in' => :'Any', + :'not_in' => :'Any' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsFiltersCondition` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsFiltersCondition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'is') + self.is = attributes[:'is'] + end + + if attributes.key?(:'is_not') + self.is_not = attributes[:'is_not'] + end + + if attributes.key?(:'has_value') + self.has_value = attributes[:'has_value'] + end + + if attributes.key?(:'is_unknown') + self.is_unknown = attributes[:'is_unknown'] + end + + if attributes.key?(:'_in') + self._in = attributes[:'_in'] + end + + if attributes.key?(:'not_in') + self.not_in = attributes[:'not_in'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + is == o.is && + is_not == o.is_not && + has_value == o.has_value && + is_unknown == o.is_unknown && + _in == o._in && + not_in == o.not_in + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [is, is_not, has_value, is_unknown, _in, not_in].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_option.rb b/lib/VoucherifySdk/models/qualifications_option.rb new file mode 100644 index 00000000..9898d423 --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_option.rb @@ -0,0 +1,311 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Configure parameters returned in the response. + class QualificationsOption + # The maximum number of redeemables to be returned in the API request. The actual number of returned redeemables will be determined by the API. The default value is set to 5 + attr_accessor :limit + + # Cursor used for paging. + attr_accessor :starting_after + + attr_accessor :filters + + # The expand array lets you configure the parameters included in the response. Depending on the strings included in the array, the response will contain different details. | **Expand Option** | **Response Body** | |:---|:---| | [\"redeemable\"] | - Returns the redeemables' metadata. | | [\"category\"] | - Returns an expanded `categories` object, showing details about the category. | | [\"validation_rules\"] | - Returns an expanded `validation_rules` object, showing details about the validation rules. | + attr_accessor :expand + + # Is used to determine the order in which data is displayed in the result array. - `DEFAULT` - Sorting descending by `created_at` - `BEST_DEAL` - Sorting descending by `total_applied_discount_amount` - `LEAST_DEAL` - Sorting ascending by `total_applied_discount_amount` + attr_accessor :sorting_rule + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'limit' => :'limit', + :'starting_after' => :'starting_after', + :'filters' => :'filters', + :'expand' => :'expand', + :'sorting_rule' => :'sorting_rule' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'limit' => :'Integer', + :'starting_after' => :'Time', + :'filters' => :'QualificationsOptionFilters', + :'expand' => :'Array', + :'sorting_rule' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'starting_after', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsOption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsOption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'limit') + self.limit = attributes[:'limit'] + end + + if attributes.key?(:'starting_after') + self.starting_after = attributes[:'starting_after'] + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + end + + if attributes.key?(:'expand') + if (value = attributes[:'expand']).is_a?(Array) + self.expand = value + end + end + + if attributes.key?(:'sorting_rule') + self.sorting_rule = attributes[:'sorting_rule'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@limit.nil? && @limit > 100 + invalid_properties.push('invalid value for "limit", must be smaller than or equal to 100.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@limit.nil? && @limit > 100 + sorting_rule_validator = EnumAttributeValidator.new('String', ["BEST_DEAL", "LEAST_DEAL", "DEFAULT"]) + return false unless sorting_rule_validator.valid?(@sorting_rule) + true + end + + # Custom attribute writer method with validation + # @param [Object] limit Value to be assigned + def limit=(limit) + if limit.nil? + fail ArgumentError, 'limit cannot be nil' + end + + if limit > 100 + fail ArgumentError, 'invalid value for "limit", must be smaller than or equal to 100.' + end + + @limit = limit + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] sorting_rule Object to be assigned + def sorting_rule=(sorting_rule) + validator = EnumAttributeValidator.new('String', ["BEST_DEAL", "LEAST_DEAL", "DEFAULT"]) + unless validator.valid?(sorting_rule) + fail ArgumentError, "invalid value for \"sorting_rule\", must be one of #{validator.allowable_values}." + end + @sorting_rule = sorting_rule + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + limit == o.limit && + starting_after == o.starting_after && + filters == o.filters && + expand == o.expand && + sorting_rule == o.sorting_rule + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [limit, starting_after, filters, expand, sorting_rule].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_option_filters.rb b/lib/VoucherifySdk/models/qualifications_option_filters.rb new file mode 100644 index 00000000..71e54e77 --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_option_filters.rb @@ -0,0 +1,291 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # A set of filters to return only a specific category or type of redeemable. + class QualificationsOptionFilters + attr_accessor :junction + + attr_accessor :category_id + + attr_accessor :campaign_id + + attr_accessor :resource_id + + attr_accessor :resource_type + + attr_accessor :voucher_type + + attr_accessor :code + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'junction' => :'junction', + :'category_id' => :'category_id', + :'campaign_id' => :'campaign_id', + :'resource_id' => :'resource_id', + :'resource_type' => :'resource_type', + :'voucher_type' => :'voucher_type', + :'code' => :'code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'junction' => :'Junction', + :'category_id' => :'QualificationsFieldConditions', + :'campaign_id' => :'QualificationsFieldConditions', + :'resource_id' => :'QualificationsFieldConditions', + :'resource_type' => :'QualificationsOptionFiltersResourceType', + :'voucher_type' => :'QualificationsFieldConditions', + :'code' => :'QualificationsFieldConditions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsOptionFilters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsOptionFilters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'junction') + self.junction = attributes[:'junction'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'resource_id') + self.resource_id = attributes[:'resource_id'] + end + + if attributes.key?(:'resource_type') + self.resource_type = attributes[:'resource_type'] + end + + if attributes.key?(:'voucher_type') + self.voucher_type = attributes[:'voucher_type'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + junction == o.junction && + category_id == o.category_id && + campaign_id == o.campaign_id && + resource_id == o.resource_id && + resource_type == o.resource_type && + voucher_type == o.voucher_type && + code == o.code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [junction, category_id, campaign_id, resource_id, resource_type, voucher_type, code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_option_filters_resource_type.rb b/lib/VoucherifySdk/models/qualifications_option_filters_resource_type.rb new file mode 100644 index 00000000..5e84e3ad --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_option_filters_resource_type.rb @@ -0,0 +1,214 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class QualificationsOptionFiltersResourceType + attr_accessor :conditions + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'QualificationsOptionFiltersResourceTypeConditions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsOptionFiltersResourceType` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsOptionFiltersResourceType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_option_filters_resource_type_conditions.rb b/lib/VoucherifySdk/models/qualifications_option_filters_resource_type_conditions.rb new file mode 100644 index 00000000..dfe6d38c --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_option_filters_resource_type_conditions.rb @@ -0,0 +1,270 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Data filters used to narrow the data records to be returned in the result. + class QualificationsOptionFiltersResourceTypeConditions + attr_accessor :is + + attr_accessor :is_not + + # Array of qualified redeemables. Accepts more than one value. Returns the resource types entered in the array. + attr_accessor :_in + + # Array of qualified redeemables. Accepts more than one value. Returns the resource types except those entered in the array. + attr_accessor :not_in + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'is' => :'$is', + :'is_not' => :'$is_not', + :'_in' => :'$in', + :'not_in' => :'$not_in' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'is' => :'ResourceTypes', + :'is_not' => :'ResourceTypes', + :'_in' => :'Array', + :'not_in' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsOptionFiltersResourceTypeConditions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsOptionFiltersResourceTypeConditions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'is') + self.is = attributes[:'is'] + end + + if attributes.key?(:'is_not') + self.is_not = attributes[:'is_not'] + end + + if attributes.key?(:'_in') + if (value = attributes[:'_in']).is_a?(Array) + self._in = value + end + end + + if attributes.key?(:'not_in') + if (value = attributes[:'not_in']).is_a?(Array) + self.not_in = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + is == o.is && + is_not == o.is_not && + _in == o._in && + not_in == o.not_in + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [is, is_not, _in, not_in].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_redeemable.rb b/lib/VoucherifySdk/models/qualifications_redeemable.rb new file mode 100644 index 00000000..31eafabf --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_redeemable.rb @@ -0,0 +1,404 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class QualificationsRedeemable + # Id of the redeemable. + attr_accessor :id + + # Object type of the redeemable. + attr_accessor :object + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :created_at + + attr_accessor :result + + attr_accessor :order + + # A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. + attr_accessor :validation_rule_id + + attr_accessor :applicable_to + + attr_accessor :inapplicable_to + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # List of category information. + attr_accessor :categories + + # Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. + attr_accessor :banner + + # Name of the redeemable. + attr_accessor :name + + # Name of the campaign associated to the redeemable. This field is available only if object is not `campaign` + attr_accessor :campaign_name + + # Id of the campaign associated to the redeemable. This field is available only if object is not `campaign` + attr_accessor :campaign_id + + attr_accessor :validation_rules_assignments + + attr_accessor :redeemables + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'result' => :'result', + :'order' => :'order', + :'validation_rule_id' => :'validation_rule_id', + :'applicable_to' => :'applicable_to', + :'inapplicable_to' => :'inapplicable_to', + :'metadata' => :'metadata', + :'categories' => :'categories', + :'banner' => :'banner', + :'name' => :'name', + :'campaign_name' => :'campaign_name', + :'campaign_id' => :'campaign_id', + :'validation_rules_assignments' => :'validation_rules_assignments', + :'redeemables' => :'redeemables' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'result' => :'RedeemableResult', + :'order' => :'OrderCalculated', + :'validation_rule_id' => :'String', + :'applicable_to' => :'ApplicableToResultList', + :'inapplicable_to' => :'InapplicableToResultList', + :'metadata' => :'Object', + :'categories' => :'Array', + :'banner' => :'String', + :'name' => :'String', + :'campaign_name' => :'String', + :'campaign_id' => :'String', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList', + :'redeemables' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'QualificationsRedeemableBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsRedeemable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsRedeemable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'validation_rule_id') + self.validation_rule_id = attributes[:'validation_rule_id'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + end + + if attributes.key?(:'inapplicable_to') + self.inapplicable_to = attributes[:'inapplicable_to'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'campaign_name') + self.campaign_name = attributes[:'campaign_name'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["campaign", "promotion_tier", "promotion_stack", "voucher"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["campaign", "promotion_tier", "promotion_stack", "voucher"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + result == o.result && + order == o.order && + validation_rule_id == o.validation_rule_id && + applicable_to == o.applicable_to && + inapplicable_to == o.inapplicable_to && + metadata == o.metadata && + categories == o.categories && + banner == o.banner && + name == o.name && + campaign_name == o.campaign_name && + campaign_id == o.campaign_id && + validation_rules_assignments == o.validation_rules_assignments && + redeemables == o.redeemables + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, result, order, validation_rule_id, applicable_to, inapplicable_to, metadata, categories, banner, name, campaign_name, campaign_id, validation_rules_assignments, redeemables].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_redeemable_base.rb b/lib/VoucherifySdk/models/qualifications_redeemable_base.rb new file mode 100644 index 00000000..938b84f6 --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_redeemable_base.rb @@ -0,0 +1,387 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Data of single redeemable which was properly qualified. + class QualificationsRedeemableBase + # Id of the redeemable. + attr_accessor :id + + # Object type of the redeemable. + attr_accessor :object + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :created_at + + attr_accessor :result + + attr_accessor :order + + # A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance. + attr_accessor :validation_rule_id + + attr_accessor :applicable_to + + attr_accessor :inapplicable_to + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # List of category information. + attr_accessor :categories + + # Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. + attr_accessor :banner + + # Name of the redeemable. + attr_accessor :name + + # Name of the campaign associated to the redeemable. This field is available only if object is not `campaign` + attr_accessor :campaign_name + + # Id of the campaign associated to the redeemable. This field is available only if object is not `campaign` + attr_accessor :campaign_id + + attr_accessor :validation_rules_assignments + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'result' => :'result', + :'order' => :'order', + :'validation_rule_id' => :'validation_rule_id', + :'applicable_to' => :'applicable_to', + :'inapplicable_to' => :'inapplicable_to', + :'metadata' => :'metadata', + :'categories' => :'categories', + :'banner' => :'banner', + :'name' => :'name', + :'campaign_name' => :'campaign_name', + :'campaign_id' => :'campaign_id', + :'validation_rules_assignments' => :'validation_rules_assignments' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'result' => :'RedeemableResult', + :'order' => :'OrderCalculated', + :'validation_rule_id' => :'String', + :'applicable_to' => :'ApplicableToResultList', + :'inapplicable_to' => :'InapplicableToResultList', + :'metadata' => :'Object', + :'categories' => :'Array', + :'banner' => :'String', + :'name' => :'String', + :'campaign_name' => :'String', + :'campaign_id' => :'String', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsRedeemableBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsRedeemableBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'validation_rule_id') + self.validation_rule_id = attributes[:'validation_rule_id'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + end + + if attributes.key?(:'inapplicable_to') + self.inapplicable_to = attributes[:'inapplicable_to'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'campaign_name') + self.campaign_name = attributes[:'campaign_name'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["campaign", "promotion_tier", "promotion_stack", "voucher"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["campaign", "promotion_tier", "promotion_stack", "voucher"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + result == o.result && + order == o.order && + validation_rule_id == o.validation_rule_id && + applicable_to == o.applicable_to && + inapplicable_to == o.inapplicable_to && + metadata == o.metadata && + categories == o.categories && + banner == o.banner && + name == o.name && + campaign_name == o.campaign_name && + campaign_id == o.campaign_id && + validation_rules_assignments == o.validation_rules_assignments + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, result, order, validation_rule_id, applicable_to, inapplicable_to, metadata, categories, banner, name, campaign_name, campaign_id, validation_rules_assignments].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/qualifications_redeemables.rb b/lib/VoucherifySdk/models/qualifications_redeemables.rb new file mode 100644 index 00000000..2c5c8791 --- /dev/null +++ b/lib/VoucherifySdk/models/qualifications_redeemables.rb @@ -0,0 +1,349 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of redeemables for examine qualification. + class QualificationsRedeemables + # The type of object represented by JSON. Default is `list`. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of qualified redeemables. + attr_accessor :data_ref + + # Array of qualified redeemables. + attr_accessor :data + + # The number of redeemables returned in the API request. + attr_accessor :total + + # As results are always limited, the `has_more` flag indicates whether there are more records for given parameters. This let's you know if you are able to run another request (with different options) to get more records returned in the results. + attr_accessor :has_more + + # Timestamp representing the date and time to use in starting_after cursor to get more redeemables. + attr_accessor :more_starting_after + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total', + :'has_more' => :'has_more', + :'more_starting_after' => :'more_starting_after' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer', + :'has_more' => :'Boolean', + :'more_starting_after' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::QualificationsRedeemables` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::QualificationsRedeemables`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + else + self.has_more = nil + end + + if attributes.key?(:'more_starting_after') + self.more_starting_after = attributes[:'more_starting_after'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @has_more.nil? + invalid_properties.push('invalid value for "has_more", has_more cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + return false if @has_more.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total && + has_more == o.has_more && + more_starting_after == o.more_starting_after + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total, has_more, more_starting_after].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeem_gift_card.rb b/lib/VoucherifySdk/models/redeem_gift_card.rb new file mode 100644 index 00000000..53a0cb58 --- /dev/null +++ b/lib/VoucherifySdk/models/redeem_gift_card.rb @@ -0,0 +1,289 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedeemGiftCard + # Redeemable object type. + attr_accessor :object + + # Redeemable code. + attr_accessor :id + + attr_accessor :gift + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'id' => :'id', + :'gift' => :'gift' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'id' => :'String', + :'gift' => :'RedeemGiftCardAllOfGift' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RedeemVoucher' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemGiftCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemGiftCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + id == o.id && + gift == o.gift + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, id, gift].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeem_gift_card_all_of_gift.rb b/lib/VoucherifySdk/models/redeem_gift_card_all_of_gift.rb new file mode 100644 index 00000000..5ec78f0e --- /dev/null +++ b/lib/VoucherifySdk/models/redeem_gift_card_all_of_gift.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information on the number of gift card credits that the customer wants to apply to the order. + class RedeemGiftCardAllOfGift + # The number of credits that the user wants to use from the gift card to fulfill the order. The value of credits cannot be higher than the current balance on the gift card. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :credits + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'credits' => :'credits' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'credits' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemGiftCardAllOfGift` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemGiftCardAllOfGift`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'credits') + self.credits = attributes[:'credits'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + credits == o.credits + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [credits].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeem_loyalty_card.rb b/lib/VoucherifySdk/models/redeem_loyalty_card.rb new file mode 100644 index 00000000..56cf7c59 --- /dev/null +++ b/lib/VoucherifySdk/models/redeem_loyalty_card.rb @@ -0,0 +1,289 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedeemLoyaltyCard + # Redeemable object type. + attr_accessor :object + + # Redeemable code. + attr_accessor :id + + attr_accessor :reward + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'id' => :'id', + :'reward' => :'reward' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'id' => :'String', + :'reward' => :'RedeemLoyaltyCardAllOfReward' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RedeemVoucher' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + id == o.id && + reward == o.reward + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, id, reward].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeem_loyalty_card_all_of_reward.rb b/lib/VoucherifySdk/models/redeem_loyalty_card_all_of_reward.rb new file mode 100644 index 00000000..fabe8d03 --- /dev/null +++ b/lib/VoucherifySdk/models/redeem_loyalty_card_all_of_reward.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the reward that the customer wants to redeem and the number of points the customer is choosing to use for the reward. + class RedeemLoyaltyCardAllOfReward + # Unique reward ID assigned by Voucherify. The reward must be assigned to the campaign in order for the user to be able to use the reward. + attr_accessor :id + + # The number of loyalty points that the user wants to spend in order to fulfill the order using a **pay with points** reward. The number of points cannot be higher than the current balance on the loyalty card. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemLoyaltyCardAllOfReward` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemLoyaltyCardAllOfReward`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeem_promotion_stack.rb b/lib/VoucherifySdk/models/redeem_promotion_stack.rb new file mode 100644 index 00000000..a74e7e6a --- /dev/null +++ b/lib/VoucherifySdk/models/redeem_promotion_stack.rb @@ -0,0 +1,274 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Redeem a discount code. + class RedeemPromotionStack + # Redeemable object type. + attr_accessor :object + + # Promotion stack unique id, such as: stack_KxSD0GahLUg9ULB6TseGfUHJ + attr_accessor :id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemPromotionStack` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemPromotionStack`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_stack' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["promotion_stack"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeem_promotion_tier.rb b/lib/VoucherifySdk/models/redeem_promotion_tier.rb new file mode 100644 index 00000000..9a5290fa --- /dev/null +++ b/lib/VoucherifySdk/models/redeem_promotion_tier.rb @@ -0,0 +1,274 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Redeem a discount code. + class RedeemPromotionTier + # Redeemable object type. + attr_accessor :object + + # Promotion tier unique id, such as: promo_Mwy9XpA0TLctSGriM5kum0qp + attr_accessor :id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemPromotionTier` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemPromotionTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'promotion_tier' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["promotion_tier"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["promotion_tier"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeem_voucher.rb b/lib/VoucherifySdk/models/redeem_voucher.rb new file mode 100644 index 00000000..010333cc --- /dev/null +++ b/lib/VoucherifySdk/models/redeem_voucher.rb @@ -0,0 +1,274 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Redeem a discount code. + class RedeemVoucher + # Redeemable object type. + attr_accessor :object + + # Redeemable code. + attr_accessor :id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless object_validator.valid?(@object) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_gift.rb b/lib/VoucherifySdk/models/redeemable_gift.rb new file mode 100644 index 00000000..a0450dab --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_gift.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains current gift card balance information. + class RedeemableGift + # Available funds. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :balance + + # The number of credits that the user wants to use from the gift card to fulfil the order. The value of credits cannot be higher than the current balance on the gift card. If the user gives more points than he has on the gift card, the application will return an error code in response. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :credits + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'balance' => :'balance', + :'credits' => :'credits' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'balance' => :'Float', + :'credits' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableGift` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableGift`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'credits') + self.credits = attributes[:'credits'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + balance == o.balance && + credits == o.credits + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [balance, credits].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_loyalty_card.rb b/lib/VoucherifySdk/models/redeemable_loyalty_card.rb new file mode 100644 index 00000000..29dc9820 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_loyalty_card.rb @@ -0,0 +1,257 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Redeemable loyalty card object response + class RedeemableLoyaltyCard + # Total points incurred over lifespan of loyalty card. + attr_accessor :points + + # Points available for reward redemption. + attr_accessor :balance + + # The cash equivalent of the points defined in the points_ratio property. + attr_accessor :exchange_ratio + + # The number of loyalty points that will map to the predefined cash amount defined by the exchange_ratio property. + attr_accessor :points_ratio + + attr_accessor :transfers + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'balance' => :'balance', + :'exchange_ratio' => :'exchange_ratio', + :'points_ratio' => :'points_ratio', + :'transfers' => :'transfers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'balance' => :'Integer', + :'exchange_ratio' => :'Float', + :'points_ratio' => :'Integer', + :'transfers' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'exchange_ratio') + self.exchange_ratio = attributes[:'exchange_ratio'] + end + + if attributes.key?(:'points_ratio') + self.points_ratio = attributes[:'points_ratio'] + end + + if attributes.key?(:'transfers') + if (value = attributes[:'transfers']).is_a?(Array) + self.transfers = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + balance == o.balance && + exchange_ratio == o.exchange_ratio && + points_ratio == o.points_ratio && + transfers == o.transfers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, balance, exchange_ratio, points_ratio, transfers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result.rb b/lib/VoucherifySdk/models/redeemable_result.rb new file mode 100644 index 00000000..53f8b5f3 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result.rb @@ -0,0 +1,242 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Information about redeemable result. + class RedeemableResult + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + attr_accessor :error + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'error' => :'error' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'discount' => :'Discount', + :'gift' => :'RedeemableGift', + :'loyalty_card' => :'RedeemableLoyaltyCard', + :'error' => :'Error' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + error == o.error + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [discount, gift, loyalty_card, error].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_gift_card.rb b/lib/VoucherifySdk/models/redeemable_result_gift_card.rb new file mode 100644 index 00000000..0500b832 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_gift_card.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is a `result` object representing the results for a gift card. + class RedeemableResultGiftCard + attr_accessor :gift + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'gift' => :'gift' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'gift' => :'RedeemableResultGiftCardGift' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResultGiftCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResultGiftCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + gift == o.gift + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [gift].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_gift_card_gift.rb b/lib/VoucherifySdk/models/redeemable_result_gift_card_gift.rb new file mode 100644 index 00000000..29c28720 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_gift_card_gift.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores the amount of gift card credits to be applied in the redemption. + class RedeemableResultGiftCardGift + # Total number of gift card credits to be applied in the redemption expressed as the smallest currency unit (e.g. 100 cents for $1.00). + attr_accessor :credits + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'credits' => :'credits' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'credits' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResultGiftCardGift` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResultGiftCardGift`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'credits') + self.credits = attributes[:'credits'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + credits == o.credits + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [credits].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_loyalty_card.rb b/lib/VoucherifySdk/models/redeemable_result_loyalty_card.rb new file mode 100644 index 00000000..eb40972b --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_loyalty_card.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is a `result` object representing the results for a loyalty card. + class RedeemableResultLoyaltyCard + attr_accessor :loyalty_card + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'loyalty_card' => :'RedeemableResultLoyaltyCardLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResultLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResultLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_loyalty_card_loyalty_card.rb b/lib/VoucherifySdk/models/redeemable_result_loyalty_card_loyalty_card.rb new file mode 100644 index 00000000..bc392171 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_loyalty_card_loyalty_card.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores the amount of loyalty card points to be applied in the redemption. + class RedeemableResultLoyaltyCardLoyaltyCard + # Total number of loyalty points to be applied in the redemption. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResultLoyaltyCardLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResultLoyaltyCardLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_promotion_stack.rb b/lib/VoucherifySdk/models/redeemable_result_promotion_stack.rb new file mode 100644 index 00000000..83d787b0 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_promotion_stack.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is a `result` object representing the results for a promotion stack. + class RedeemableResultPromotionStack + attr_accessor :loyalty_card + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'loyalty_card' => :'RedeemableResultLoyaltyCardLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResultPromotionStack` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResultPromotionStack`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_promotion_tier.rb b/lib/VoucherifySdk/models/redeemable_result_promotion_tier.rb new file mode 100644 index 00000000..3adb762d --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_promotion_tier.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is a `result` object representing the results for a promotion tier. + class RedeemableResultPromotionTier + attr_accessor :discount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'discount' => :'discount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'discount' => :'RedeemableResultPromotionTierDiscount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResultPromotionTier` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResultPromotionTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + discount == o.discount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [discount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_promotion_tier_discount.rb b/lib/VoucherifySdk/models/redeemable_result_promotion_tier_discount.rb new file mode 100644 index 00000000..edf45646 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_promotion_tier_discount.rb @@ -0,0 +1,109 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Discount details about the type of discount to be applied for the redeemable. + module RedeemableResultPromotionTierDiscount + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'DiscountAmount', + :'DiscountFixed', + :'DiscountPercent', + :'DiscountUnit', + :'DiscountUnitMultiple' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/redeemable_result_voucher_code.rb b/lib/VoucherifySdk/models/redeemable_result_voucher_code.rb new file mode 100644 index 00000000..bdcc7452 --- /dev/null +++ b/lib/VoucherifySdk/models/redeemable_result_voucher_code.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is a `result` object representing the results for a coupon code. + class RedeemableResultVoucherCode + attr_accessor :discount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'discount' => :'discount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'discount' => :'RedeemableResultPromotionTierDiscount' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedeemableResultVoucherCode` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedeemableResultVoucherCode`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + discount == o.discount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [discount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption.rb b/lib/VoucherifySdk/models/redemption.rb new file mode 100644 index 00000000..2f756976 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption.rb @@ -0,0 +1,571 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a redemption. + class Redemption + # Unique redemption ID. + attr_accessor :id + + # The type of object represented by the JSON + attr_accessor :object + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Unique customer ID of the redeeming customer. + attr_accessor :customer_id + + # Hashed customer source ID. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the redemption. + attr_accessor :metadata + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Unique redemption ID of the parent redemption. + attr_accessor :redemption + + # Redemption result. + attr_accessor :result + + # Redemption status. + attr_accessor :status + + attr_accessor :related_redemptions + + # If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. + attr_accessor :failure_code + + # If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. + attr_accessor :failure_message + + attr_accessor :order + + attr_accessor :channel + + attr_accessor :customer + + # Defines the related object. + attr_accessor :related_object_type + + # Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. + attr_accessor :related_object_id + + attr_accessor :voucher + + attr_accessor :promotion_tier + + attr_accessor :reward + + attr_accessor :gift + + attr_accessor :loyalty_card + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'date' => :'date', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'amount' => :'amount', + :'redemption' => :'redemption', + :'result' => :'result', + :'status' => :'status', + :'related_redemptions' => :'related_redemptions', + :'failure_code' => :'failure_code', + :'failure_message' => :'failure_message', + :'order' => :'order', + :'channel' => :'channel', + :'customer' => :'customer', + :'related_object_type' => :'related_object_type', + :'related_object_id' => :'related_object_id', + :'voucher' => :'voucher', + :'promotion_tier' => :'promotion_tier', + :'reward' => :'reward', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'date' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'amount' => :'Integer', + :'redemption' => :'String', + :'result' => :'String', + :'status' => :'String', + :'related_redemptions' => :'RedemptionRelatedRedemptions', + :'failure_code' => :'String', + :'failure_message' => :'String', + :'order' => :'OrderCalculatedNoCustomerData', + :'channel' => :'RedemptionChannel', + :'customer' => :'SimpleCustomer', + :'related_object_type' => :'String', + :'related_object_id' => :'String', + :'voucher' => :'Voucher', + :'promotion_tier' => :'PromotionTier', + :'reward' => :'RedemptionRewardResult', + :'gift' => :'RedemptionGift', + :'loyalty_card' => :'RedemptionLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer_id', + :'tracking_id', + :'metadata', + :'redemption', + :'order', + :'customer', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Redemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Redemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'redemption' + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + else + self.date = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + else + self.tracking_id = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + else + self.redemption = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'related_redemptions') + self.related_redemptions = attributes[:'related_redemptions'] + end + + if attributes.key?(:'failure_code') + self.failure_code = attributes[:'failure_code'] + end + + if attributes.key?(:'failure_message') + self.failure_message = attributes[:'failure_message'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + else + self.order = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @date.nil? + invalid_properties.push('invalid value for "date", date cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["redemption"]) + return false unless object_validator.valid?(@object) + return false if @date.nil? + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + return false unless result_validator.valid?(@result) + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED", "ROLLED_BACK"]) + return false unless status_validator.valid?(@status) + return false if @channel.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + return false unless related_object_type_validator.valid?(@related_object_type) + return false if @related_object_id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["redemption"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED", "ROLLED_BACK"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + date == o.date && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + amount == o.amount && + redemption == o.redemption && + result == o.result && + status == o.status && + related_redemptions == o.related_redemptions && + failure_code == o.failure_code && + failure_message == o.failure_message && + order == o.order && + channel == o.channel && + customer == o.customer && + related_object_type == o.related_object_type && + related_object_id == o.related_object_id && + voucher == o.voucher && + promotion_tier == o.promotion_tier && + reward == o.reward && + gift == o.gift && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, date, customer_id, tracking_id, metadata, amount, redemption, result, status, related_redemptions, failure_code, failure_message, order, channel, customer, related_object_type, related_object_id, voucher, promotion_tier, reward, gift, loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_channel.rb b/lib/VoucherifySdk/models/redemption_channel.rb new file mode 100644 index 00000000..5b2dd502 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_channel.rb @@ -0,0 +1,260 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the details of the channel through which the redemption was issued. + class RedemptionChannel + # Unique channel ID of the user performing the redemption. This is either a user ID from a user using the Voucherify Dashboard or an X-APP-Id of a user using the API. + attr_accessor :channel_id + + # The source of the channel for the redemption. A `USER` corresponds to the Voucherify Dashboard and an `API` corresponds to the API. + attr_accessor :channel_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'channel_id' => :'channel_id', + :'channel_type' => :'channel_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'channel_id' => :'String', + :'channel_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionChannel` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionChannel`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'channel_id') + self.channel_id = attributes[:'channel_id'] + end + + if attributes.key?(:'channel_type') + self.channel_type = attributes[:'channel_type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + channel_type_validator = EnumAttributeValidator.new('String', ["USER", "API"]) + return false unless channel_type_validator.valid?(@channel_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel_type Object to be assigned + def channel_type=(channel_type) + validator = EnumAttributeValidator.new('String', ["USER", "API"]) + unless validator.valid?(channel_type) + fail ArgumentError, "invalid value for \"channel_type\", must be one of #{validator.allowable_values}." + end + @channel_type = channel_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + channel_id == o.channel_id && + channel_type == o.channel_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [channel_id, channel_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_gift.rb b/lib/VoucherifySdk/models/redemption_gift.rb new file mode 100644 index 00000000..8aa5b9e1 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_gift.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the amount being subtracted from the gift card for the redemption. + class RedemptionGift + # The amount subtracted from the gift card expressed as the smallest currency unit (e.g. 100 cents for $1.00). + attr_accessor :amount + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionGift` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionGift`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_internal.rb b/lib/VoucherifySdk/models/redemption_internal.rb new file mode 100644 index 00000000..3db4e159 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_internal.rb @@ -0,0 +1,542 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Model Used for internal communication + class RedemptionInternal + # Unique redemption ID. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the `redemption`. + attr_accessor :object + + # Timestamp representing the date and time when the redemption was created in ISO 8601 format. + attr_accessor :created_at + + # Hashed customer source ID. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the redemption. + attr_accessor :metadata + + # The source of the channel for the redemption rollback. A `USER` corresponds to the Voucherify Dashboard and an `API` corresponds to the API. + attr_accessor :channel_type + + # Unique channel ID of the user performing the redemption. This is either a user ID from a user using the Voucherify Dashboard or an X-APP-Id of a user using the API. + attr_accessor :channel_id + + # If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. + attr_accessor :failure_code + + # If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. + attr_accessor :failure_message + + attr_accessor :order + + attr_accessor :previous_order + + attr_accessor :reward + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # System generated cause for the redemption being invalid in the context of the provided parameters. + attr_accessor :reason + + # Redemption result. + attr_accessor :result + + # Redemption status. + attr_accessor :status + + attr_accessor :related_redemptions + + # Unique redemption ID of the parent redemption. + attr_accessor :parent_redemption_id + + # Unique redemption ID of the parent redemption. + attr_accessor :redemption + + attr_accessor :customer + + # Unique customer ID of the redeeming customer. + attr_accessor :customer_id + + # Defines the related object. + attr_accessor :related_object_type + + # Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. + attr_accessor :related_object_id + + # Unique related parent object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. + attr_accessor :related_object_parent_id + + # Campaign name + attr_accessor :campaign_name + + attr_accessor :voucher + + attr_accessor :promotion_tier + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'channel_type' => :'channel_type', + :'channel_id' => :'channel_id', + :'failure_code' => :'failure_code', + :'failure_message' => :'failure_message', + :'order' => :'order', + :'previous_order' => :'previous_order', + :'reward' => :'reward', + :'amount' => :'amount', + :'reason' => :'reason', + :'result' => :'result', + :'status' => :'status', + :'related_redemptions' => :'related_redemptions', + :'parent_redemption_id' => :'parent_redemption_id', + :'redemption' => :'redemption', + :'customer' => :'customer', + :'customer_id' => :'customer_id', + :'related_object_type' => :'related_object_type', + :'related_object_id' => :'related_object_id', + :'related_object_parent_id' => :'related_object_parent_id', + :'campaign_name' => :'campaign_name', + :'voucher' => :'voucher', + :'promotion_tier' => :'promotion_tier' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'channel_type' => :'String', + :'channel_id' => :'String', + :'failure_code' => :'String', + :'failure_message' => :'String', + :'order' => :'OrderCalculated', + :'previous_order' => :'OrderCalculated', + :'reward' => :'RedemptionRewardResult', + :'amount' => :'Integer', + :'reason' => :'String', + :'result' => :'String', + :'status' => :'String', + :'related_redemptions' => :'RedemptionInternalRelatedRedemptions', + :'parent_redemption_id' => :'String', + :'redemption' => :'String', + :'customer' => :'SimpleCustomer', + :'customer_id' => :'String', + :'related_object_type' => :'String', + :'related_object_id' => :'String', + :'related_object_parent_id' => :'String', + :'campaign_name' => :'String', + :'voucher' => :'Voucher', + :'promotion_tier' => :'PromotionTier' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionInternal` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionInternal`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'redemption' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'channel_type') + self.channel_type = attributes[:'channel_type'] + end + + if attributes.key?(:'channel_id') + self.channel_id = attributes[:'channel_id'] + end + + if attributes.key?(:'failure_code') + self.failure_code = attributes[:'failure_code'] + end + + if attributes.key?(:'failure_message') + self.failure_message = attributes[:'failure_message'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'previous_order') + self.previous_order = attributes[:'previous_order'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'related_redemptions') + self.related_redemptions = attributes[:'related_redemptions'] + end + + if attributes.key?(:'parent_redemption_id') + self.parent_redemption_id = attributes[:'parent_redemption_id'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + end + + if attributes.key?(:'related_object_parent_id') + self.related_object_parent_id = attributes[:'related_object_parent_id'] + end + + if attributes.key?(:'campaign_name') + self.campaign_name = attributes[:'campaign_name'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + channel_type_validator = EnumAttributeValidator.new('String', ["USER", "API"]) + return false unless channel_type_validator.valid?(@channel_type) + result_validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + return false unless result_validator.valid?(@result) + status_validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED"]) + return false unless status_validator.valid?(@status) + related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] channel_type Object to be assigned + def channel_type=(channel_type) + validator = EnumAttributeValidator.new('String', ["USER", "API"]) + unless validator.valid?(channel_type) + fail ArgumentError, "invalid value for \"channel_type\", must be one of #{validator.allowable_values}." + end + @channel_type = channel_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + tracking_id == o.tracking_id && + metadata == o.metadata && + channel_type == o.channel_type && + channel_id == o.channel_id && + failure_code == o.failure_code && + failure_message == o.failure_message && + order == o.order && + previous_order == o.previous_order && + reward == o.reward && + amount == o.amount && + reason == o.reason && + result == o.result && + status == o.status && + related_redemptions == o.related_redemptions && + parent_redemption_id == o.parent_redemption_id && + redemption == o.redemption && + customer == o.customer && + customer_id == o.customer_id && + related_object_type == o.related_object_type && + related_object_id == o.related_object_id && + related_object_parent_id == o.related_object_parent_id && + campaign_name == o.campaign_name && + voucher == o.voucher && + promotion_tier == o.promotion_tier + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, tracking_id, metadata, channel_type, channel_id, failure_code, failure_message, order, previous_order, reward, amount, reason, result, status, related_redemptions, parent_redemption_id, redemption, customer, customer_id, related_object_type, related_object_id, related_object_parent_id, campaign_name, voucher, promotion_tier].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_internal_related_redemptions.rb b/lib/VoucherifySdk/models/redemption_internal_related_redemptions.rb new file mode 100644 index 00000000..4f866beb --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_internal_related_redemptions.rb @@ -0,0 +1,227 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionInternalRelatedRedemptions + attr_accessor :rollbacks + + attr_accessor :redemptions + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'rollbacks' => :'rollbacks', + :'redemptions' => :'redemptions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'rollbacks' => :'Array', + :'redemptions' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionInternalRelatedRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionInternalRelatedRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'rollbacks') + if (value = attributes[:'rollbacks']).is_a?(Array) + self.rollbacks = value + end + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Array) + self.redemptions = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + rollbacks == o.rollbacks && + redemptions == o.redemptions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [rollbacks, redemptions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_internal_related_redemptions_item.rb b/lib/VoucherifySdk/models/redemption_internal_related_redemptions_item.rb new file mode 100644 index 00000000..2cae07ee --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_internal_related_redemptions_item.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionInternalRelatedRedemptionsItem + # Unique redemption ID. + attr_accessor :id + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'date' => :'date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionInternalRelatedRedemptionsItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionInternalRelatedRedemptionsItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + date == o.date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_internal_related_redemptions_rollbacks_item.rb b/lib/VoucherifySdk/models/redemption_internal_related_redemptions_rollbacks_item.rb new file mode 100644 index 00000000..8b65edc8 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_internal_related_redemptions_rollbacks_item.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionInternalRelatedRedemptionsRollbacksItem + # Unique rollback redemption ID. + attr_accessor :id + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'date' => :'date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionInternalRelatedRedemptionsRollbacksItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionInternalRelatedRedemptionsRollbacksItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + date == o.date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_loyalty_card.rb b/lib/VoucherifySdk/models/redemption_loyalty_card.rb new file mode 100644 index 00000000..3ec82ace --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_loyalty_card.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores the number of points being added back to the loyalty card for the reward redemption rollback. + class RedemptionLoyaltyCard + # Number of points being added back to the loyalty card for the reward redemption rollback. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_related_redemptions.rb b/lib/VoucherifySdk/models/redemption_related_redemptions.rb new file mode 100644 index 00000000..ae6c943e --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_related_redemptions.rb @@ -0,0 +1,227 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionRelatedRedemptions + attr_accessor :rollbacks + + attr_accessor :redemptions + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'rollbacks' => :'rollbacks', + :'redemptions' => :'redemptions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'rollbacks' => :'Array', + :'redemptions' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRelatedRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRelatedRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'rollbacks') + if (value = attributes[:'rollbacks']).is_a?(Array) + self.rollbacks = value + end + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Array) + self.redemptions = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + rollbacks == o.rollbacks && + redemptions == o.redemptions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [rollbacks, redemptions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_related_redemptions_item.rb b/lib/VoucherifySdk/models/redemption_related_redemptions_item.rb new file mode 100644 index 00000000..478cb311 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_related_redemptions_item.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionRelatedRedemptionsItem + # Unique redemption ID. + attr_accessor :id + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'date' => :'date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRelatedRedemptionsItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRelatedRedemptionsItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + date == o.date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_related_redemptions_rollbacks_item.rb b/lib/VoucherifySdk/models/redemption_related_redemptions_rollbacks_item.rb new file mode 100644 index 00000000..5d8e845e --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_related_redemptions_rollbacks_item.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionRelatedRedemptionsRollbacksItem + # Unique rollback redemption ID. + attr_accessor :id + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'date' => :'date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRelatedRedemptionsRollbacksItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRelatedRedemptionsRollbacksItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + date == o.date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result.rb b/lib/VoucherifySdk/models/redemption_reward_result.rb new file mode 100644 index 00000000..0bb3fc45 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result.rb @@ -0,0 +1,396 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionRewardResult + attr_accessor :customer + + # Unique reward assignment ID assigned by Voucherify. + attr_accessor :assignment_id + + attr_accessor :voucher + + attr_accessor :product + + attr_accessor :sku + + # Unique loyalty tier ID assigned by Voucherify. + attr_accessor :loyalty_tier_id + + # Unique reward ID. + attr_accessor :id + + # Name of the reward. + attr_accessor :name + + # The type of object represented by the JSON + attr_accessor :object + + # Timestamp representing the date and time when the redemption was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp in ISO 8601 format indicating when the reward was updated. + attr_accessor :updated_at + + attr_accessor :parameters + + # Reward type. + attr_accessor :type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'assignment_id' => :'assignment_id', + :'voucher' => :'voucher', + :'product' => :'product', + :'sku' => :'sku', + :'loyalty_tier_id' => :'loyalty_tier_id', + :'id' => :'id', + :'name' => :'name', + :'object' => :'object', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'parameters' => :'parameters', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'assignment_id' => :'String', + :'voucher' => :'RedemptionRewardResultVoucher', + :'product' => :'RedemptionRewardResultProduct', + :'sku' => :'RedemptionRewardResultSku', + :'loyalty_tier_id' => :'String', + :'id' => :'String', + :'name' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'parameters' => :'RedemptionRewardResultParameters', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer', + :'assignment_id', + :'voucher', + :'product', + :'sku', + :'loyalty_tier_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'assignment_id') + self.assignment_id = attributes[:'assignment_id'] + else + self.assignment_id = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + else + self.voucher = nil + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + else + self.product = nil + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + else + self.sku = nil + end + + if attributes.key?(:'loyalty_tier_id') + self.loyalty_tier_id = attributes[:'loyalty_tier_id'] + else + self.loyalty_tier_id = nil + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["reward"]) + return false unless object_validator.valid?(@object) + type_validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + assignment_id == o.assignment_id && + voucher == o.voucher && + product == o.product && + sku == o.sku && + loyalty_tier_id == o.loyalty_tier_id && + id == o.id && + name == o.name && + object == o.object && + created_at == o.created_at && + updated_at == o.updated_at && + parameters == o.parameters && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, assignment_id, voucher, product, sku, loyalty_tier_id, id, name, object, created_at, updated_at, parameters, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result_parameters.rb b/lib/VoucherifySdk/models/redemption_reward_result_parameters.rb new file mode 100644 index 00000000..8e52161d --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result_parameters.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # These are parameters representing a material reward. + class RedemptionRewardResultParameters + attr_accessor :campaign + + attr_accessor :product + + attr_accessor :coin + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'campaign' => :'campaign', + :'product' => :'product', + :'coin' => :'coin' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'campaign' => :'RedemptionRewardResultParametersCampaign', + :'product' => :'RedemptionRewardResultParametersProduct', + :'coin' => :'RedemptionRewardResultParametersCoin' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResultParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResultParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + end + + if attributes.key?(:'coin') + self.coin = attributes[:'coin'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + campaign == o.campaign && + product == o.product && + coin == o.coin + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [campaign, product, coin].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result_parameters_campaign.rb b/lib/VoucherifySdk/models/redemption_reward_result_parameters_campaign.rb new file mode 100644 index 00000000..e19e8aa0 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result_parameters_campaign.rb @@ -0,0 +1,236 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the product redeemed as a reward. + class RedemptionRewardResultParametersCampaign + # Campaign unique ID. + attr_accessor :id + + # Points available for reward redemption. + attr_accessor :balance + + # Defines the type of the campaign. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'balance' => :'balance', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'balance' => :'Integer', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResultParametersCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResultParametersCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + balance == o.balance && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, balance, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result_parameters_coin.rb b/lib/VoucherifySdk/models/redemption_reward_result_parameters_coin.rb new file mode 100644 index 00000000..1da25d9a --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result_parameters_coin.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the ratio by mapping the number of loyalty points in `points_ratio` to a predefined cash amount in `exchange_ratio`. + class RedemptionRewardResultParametersCoin + # The cash equivalent of the points defined in the `points_ratio` property. + attr_accessor :exchange_ratio + + # The number of loyalty points that will map to the predefined cash amount defined by the `exchange_ratio` property. + attr_accessor :points_ratio + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exchange_ratio' => :'exchange_ratio', + :'points_ratio' => :'points_ratio' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exchange_ratio' => :'Integer', + :'points_ratio' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResultParametersCoin` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResultParametersCoin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exchange_ratio') + self.exchange_ratio = attributes[:'exchange_ratio'] + end + + if attributes.key?(:'points_ratio') + self.points_ratio = attributes[:'points_ratio'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exchange_ratio == o.exchange_ratio && + points_ratio == o.points_ratio + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exchange_ratio, points_ratio].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result_parameters_product.rb b/lib/VoucherifySdk/models/redemption_reward_result_parameters_product.rb new file mode 100644 index 00000000..062f7abd --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result_parameters_product.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the product redeemed as a reward. + class RedemptionRewardResultParametersProduct + # Unique product ID, assigned by Voucherify. + attr_accessor :id + + # A unique SKU ID assigned by Voucherify. + attr_accessor :sku_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'sku_id' => :'sku_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'sku_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResultParametersProduct` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResultParametersProduct`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'sku_id') + self.sku_id = attributes[:'sku_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + sku_id == o.sku_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, sku_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result_product.rb b/lib/VoucherifySdk/models/redemption_reward_result_product.rb new file mode 100644 index 00000000..04216b10 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result_product.rb @@ -0,0 +1,397 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines of the product. + class RedemptionRewardResultProduct + # Unique product ID assigned by Voucherify. + attr_accessor :id + + # Unique product source ID. + attr_accessor :source_id + + # Unique user-defined product name. + attr_accessor :name + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # A list of product attributes whose values you can customize for given SKUs: `[\"color\",\"size\",\"ranking\"]`. Each child SKU can have a unique value for a given attribute. + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the product. A set of key/value pairs that you can attach to a product object. It can be useful for storing additional information about the product in a structured format. + attr_accessor :metadata + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the product image. + attr_accessor :image_url + + # Timestamp representing the date and time when the product was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the product was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the product. + attr_accessor :object + + attr_accessor :skus + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'price' => :'price', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'image_url' => :'image_url', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'skus' => :'skus' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'price' => :'Integer', + :'attributes' => :'Array', + :'metadata' => :'Object', + :'image_url' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'skus' => :'SkusListForProduct' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'name', + :'price', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Product' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResultProduct` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResultProduct`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'attributes') + if (value = attributes[:'attributes']).is_a?(Array) + self.attributes = value + end + else + self.attributes = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'product' + end + + if attributes.key?(:'skus') + self.skus = attributes[:'skus'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["product"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["product"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + price == o.price && + attributes == o.attributes && + metadata == o.metadata && + image_url == o.image_url && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + skus == o.skus + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, price, attributes, metadata, image_url, created_at, updated_at, object, skus].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result_sku.rb b/lib/VoucherifySdk/models/redemption_reward_result_sku.rb new file mode 100644 index 00000000..61dc6622 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result_sku.rb @@ -0,0 +1,425 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines of the sku. + class RedemptionRewardResultSku + # A unique identifier that represents the SKU and is assigned by Voucherify. + attr_accessor :id + + # A unique SKU identifier from your inventory system. + attr_accessor :source_id + + # The parent product's unique ID. + attr_accessor :product_id + + # Unique user-defined SKU name. + attr_accessor :sku + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the SKU was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the SKU was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the `SKU`. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'sku', + :'price', + :'currency', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Sku' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResultSku` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResultSku`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + else + self.product_id = nil + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + else + self.sku = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + else + self.attributes = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + else + self.image_url = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'sku' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @product_id.nil? + invalid_properties.push('invalid value for "product_id", product_id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @product_id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, product_id, sku, price, currency, attributes, image_url, metadata, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_reward_result_voucher.rb b/lib/VoucherifySdk/models/redemption_reward_result_voucher.rb new file mode 100644 index 00000000..d814c29c --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_reward_result_voucher.rb @@ -0,0 +1,547 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines of the voucher. + class RedemptionRewardResultVoucher + # Assigned by the Voucherify API, identifies the voucher. + attr_accessor :id + + # A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. + attr_accessor :code + + # A unique campaign name, identifies the voucher's parent campaign. + attr_accessor :campaign + + # Assigned by the Voucherify API, identifies the voucher's parent campaign. + attr_accessor :campaign_id + + # Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. + attr_accessor :category + + # Unique category ID assigned by Voucherify. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # Defines the type of the voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher + attr_accessor :active + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :assets + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Timestamp representing the date and time when the voucher was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique customer ID of voucher owner. + attr_accessor :holder_id + + attr_accessor :holder + + # The type of object represented by JSON. Default is `voucher`. + attr_accessor :object + + attr_accessor :distributions + + # Flag indicating whether this voucher is deleted. + attr_accessor :deleted + + attr_accessor :validation_rules_assignments + + attr_accessor :publish + + attr_accessor :redemption + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'category' => :'category', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'type' => :'type', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'active' => :'active', + :'additional_info' => :'additional_info', + :'metadata' => :'metadata', + :'assets' => :'assets', + :'is_referral_code' => :'is_referral_code', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'holder_id' => :'holder_id', + :'holder' => :'holder', + :'object' => :'object', + :'distributions' => :'distributions', + :'deleted' => :'deleted', + :'validation_rules_assignments' => :'validation_rules_assignments', + :'publish' => :'publish', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'campaign' => :'String', + :'campaign_id' => :'String', + :'category' => :'String', + :'category_id' => :'String', + :'categories' => :'Array', + :'type' => :'String', + :'discount' => :'Discount', + :'gift' => :'VoucherGift', + :'loyalty_card' => :'VoucherLoyaltyCard', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'VoucherValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'active' => :'Boolean', + :'additional_info' => :'String', + :'metadata' => :'Object', + :'assets' => :'VoucherAssets', + :'is_referral_code' => :'Boolean', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'holder_id' => :'String', + :'holder' => :'SimpleCustomer', + :'object' => :'String', + :'distributions' => :'Array', + :'deleted' => :'Boolean', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList', + :'publish' => :'VoucherPublish', + :'redemption' => :'VoucherRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'active', + :'is_referral_code', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Voucher' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRewardResultVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRewardResultVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'distributions') + if (value = attributes[:'distributions']).is_a?(Array) + self.distributions = value + end + end + + if attributes.key?(:'deleted') + self.deleted = attributes[:'deleted'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + + if attributes.key?(:'publish') + self.publish = attributes[:'publish'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + campaign == o.campaign && + campaign_id == o.campaign_id && + category == o.category && + category_id == o.category_id && + categories == o.categories && + type == o.type && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + active == o.active && + additional_info == o.additional_info && + metadata == o.metadata && + assets == o.assets && + is_referral_code == o.is_referral_code && + created_at == o.created_at && + updated_at == o.updated_at && + holder_id == o.holder_id && + holder == o.holder && + object == o.object && + distributions == o.distributions && + deleted == o.deleted && + validation_rules_assignments == o.validation_rules_assignments && + publish == o.publish && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, campaign, campaign_id, category, category_id, categories, type, discount, gift, loyalty_card, start_date, expiration_date, validity_timeframe, validity_day_of_week, active, additional_info, metadata, assets, is_referral_code, created_at, updated_at, holder_id, holder, object, distributions, deleted, validation_rules_assignments, publish, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_rollback.rb b/lib/VoucherifySdk/models/redemption_rollback.rb new file mode 100644 index 00000000..87103db2 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_rollback.rb @@ -0,0 +1,581 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a redemption rollback. + class RedemptionRollback + # Unique redemption ID. + attr_accessor :id + + # The type of object represented by the JSON + attr_accessor :object + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Unique customer ID of the redeeming customer. + attr_accessor :customer_id + + # Hashed customer source ID. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the redemption. + attr_accessor :metadata + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Unique redemption ID of the parent redemption. + attr_accessor :redemption + + # System generated cause for the redemption being invalid in the context of the provided parameters. + attr_accessor :reason + + # Redemption result. + attr_accessor :result + + # Redemption status. + attr_accessor :status + + attr_accessor :related_redemptions + + # If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. + attr_accessor :failure_code + + # If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. + attr_accessor :failure_message + + attr_accessor :order + + attr_accessor :channel + + attr_accessor :customer + + # Defines the related object. + attr_accessor :related_object_type + + # Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. + attr_accessor :related_object_id + + attr_accessor :voucher + + attr_accessor :promotion_tier + + attr_accessor :reward + + attr_accessor :gift + + attr_accessor :loyalty_card + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'date' => :'date', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'amount' => :'amount', + :'redemption' => :'redemption', + :'reason' => :'reason', + :'result' => :'result', + :'status' => :'status', + :'related_redemptions' => :'related_redemptions', + :'failure_code' => :'failure_code', + :'failure_message' => :'failure_message', + :'order' => :'order', + :'channel' => :'channel', + :'customer' => :'customer', + :'related_object_type' => :'related_object_type', + :'related_object_id' => :'related_object_id', + :'voucher' => :'voucher', + :'promotion_tier' => :'promotion_tier', + :'reward' => :'reward', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'date' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'amount' => :'Integer', + :'redemption' => :'String', + :'reason' => :'String', + :'result' => :'String', + :'status' => :'String', + :'related_redemptions' => :'RedemptionRollbackRelatedRedemptions', + :'failure_code' => :'String', + :'failure_message' => :'String', + :'order' => :'OrderCalculatedNoCustomerData', + :'channel' => :'RedemptionChannel', + :'customer' => :'SimpleCustomer', + :'related_object_type' => :'String', + :'related_object_id' => :'String', + :'voucher' => :'Voucher', + :'promotion_tier' => :'PromotionTier', + :'reward' => :'RedemptionRewardResult', + :'gift' => :'RedemptionGift', + :'loyalty_card' => :'RedemptionLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer_id', + :'tracking_id', + :'metadata', + :'redemption', + :'order', + :'customer', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRollback` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRollback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'redemption_rollback' + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + else + self.date = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + else + self.tracking_id = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + else + self.redemption = nil + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'related_redemptions') + self.related_redemptions = attributes[:'related_redemptions'] + end + + if attributes.key?(:'failure_code') + self.failure_code = attributes[:'failure_code'] + end + + if attributes.key?(:'failure_message') + self.failure_message = attributes[:'failure_message'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + else + self.order = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @date.nil? + invalid_properties.push('invalid value for "date", date cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["redemption_rollback"]) + return false unless object_validator.valid?(@object) + return false if @date.nil? + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + return false unless result_validator.valid?(@result) + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED"]) + return false unless status_validator.valid?(@status) + return false if @channel.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + return false unless related_object_type_validator.valid?(@related_object_type) + return false if @related_object_id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["redemption_rollback"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + date == o.date && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + amount == o.amount && + redemption == o.redemption && + reason == o.reason && + result == o.result && + status == o.status && + related_redemptions == o.related_redemptions && + failure_code == o.failure_code && + failure_message == o.failure_message && + order == o.order && + channel == o.channel && + customer == o.customer && + related_object_type == o.related_object_type && + related_object_id == o.related_object_id && + voucher == o.voucher && + promotion_tier == o.promotion_tier && + reward == o.reward && + gift == o.gift && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, date, customer_id, tracking_id, metadata, amount, redemption, reason, result, status, related_redemptions, failure_code, failure_message, order, channel, customer, related_object_type, related_object_id, voucher, promotion_tier, reward, gift, loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_rollback_related_redemptions.rb b/lib/VoucherifySdk/models/redemption_rollback_related_redemptions.rb new file mode 100644 index 00000000..f0a87e75 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_rollback_related_redemptions.rb @@ -0,0 +1,227 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionRollbackRelatedRedemptions + attr_accessor :rollbacks + + attr_accessor :redemptions + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'rollbacks' => :'rollbacks', + :'redemptions' => :'redemptions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'rollbacks' => :'Array', + :'redemptions' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRollbackRelatedRedemptions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRollbackRelatedRedemptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'rollbacks') + if (value = attributes[:'rollbacks']).is_a?(Array) + self.rollbacks = value + end + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Array) + self.redemptions = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + rollbacks == o.rollbacks && + redemptions == o.redemptions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [rollbacks, redemptions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_rollback_related_redemptions_item.rb b/lib/VoucherifySdk/models/redemption_rollback_related_redemptions_item.rb new file mode 100644 index 00000000..5b8cd798 --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_rollback_related_redemptions_item.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionRollbackRelatedRedemptionsItem + # Unique redemption ID. + attr_accessor :id + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'date' => :'date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRollbackRelatedRedemptionsItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRollbackRelatedRedemptionsItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + date == o.date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemption_rollback_related_redemptions_rollbacks_item.rb b/lib/VoucherifySdk/models/redemption_rollback_related_redemptions_rollbacks_item.rb new file mode 100644 index 00000000..7a39e30b --- /dev/null +++ b/lib/VoucherifySdk/models/redemption_rollback_related_redemptions_rollbacks_item.rb @@ -0,0 +1,225 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RedemptionRollbackRelatedRedemptionsRollbacksItem + # Unique rollback redemption ID. + attr_accessor :id + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'date' => :'date' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'date' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionRollbackRelatedRedemptionsRollbacksItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionRollbackRelatedRedemptionsRollbacksItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + date == o.date + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, date].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_get_response_body.rb b/lib/VoucherifySdk/models/redemptions_get_response_body.rb new file mode 100644 index 00000000..13f8fb83 --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_get_response_body.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/redemptions/{redemptionId} + module RedemptionsGetResponseBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'Redemption', + :'RedemptionRollback' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_list_response_body.rb b/lib/VoucherifySdk/models/redemptions_list_response_body.rb new file mode 100644 index 00000000..16fb7191 --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_list_response_body.rb @@ -0,0 +1,275 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/redemptions`. + class RedemptionsListResponseBody + # The type of object represented by JSON. This object stores information about redemptions in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of redemption objects. + attr_accessor :data_ref + + attr_accessor :redemptions + + # Total number of redemptions. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'redemptions' => :'redemptions', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'redemptions' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'redemptions' + end + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Array) + self.redemptions = value + end + else + self.redemptions = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @redemptions.nil? + invalid_properties.push('invalid value for "redemptions", redemptions cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @redemptions.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + redemptions == o.redemptions && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, redemptions, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_list_response_body_redemptions_item.rb b/lib/VoucherifySdk/models/redemptions_list_response_body_redemptions_item.rb new file mode 100644 index 00000000..d9270075 --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_list_response_body_redemptions_item.rb @@ -0,0 +1,105 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module RedemptionsListResponseBodyRedemptionsItem + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'Redemption', + :'RedemptionRollback' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_redeem_request_body.rb b/lib/VoucherifySdk/models/redemptions_redeem_request_body.rb new file mode 100644 index 00000000..77165144 --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_redeem_request_body.rb @@ -0,0 +1,316 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/redemptions`. + class RedemptionsRedeemRequestBody + # An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. + attr_accessor :redeemables + + attr_accessor :order + + attr_accessor :customer + + attr_accessor :session + + # Is correspondent to Customer's source_id + attr_accessor :tracking_id + + # A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. + attr_accessor :metadata + + attr_accessor :options + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables' => :'redeemables', + :'order' => :'order', + :'customer' => :'customer', + :'session' => :'session', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'options' => :'options' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables' => :'Array', + :'order' => :'Order', + :'customer' => :'Customer', + :'session' => :'Session', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'options' => :'ClientRedemptionsRedeemRequestBodyAllOfOptions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'StackableValidateRedeemBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionsRedeemRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionsRedeemRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + else + self.redeemables = nil + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'session') + self.session = attributes[:'session'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemables.nil? + invalid_properties.push('invalid value for "redeemables", redeemables cannot be nil.') + end + + if @redeemables.length > 5 + invalid_properties.push('invalid value for "redeemables", number of items must be less than or equal to 5.') + end + + if @redeemables.length < 1 + invalid_properties.push('invalid value for "redeemables", number of items must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemables.nil? + return false if @redeemables.length > 5 + return false if @redeemables.length < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] redeemables Value to be assigned + def redeemables=(redeemables) + if redeemables.nil? + fail ArgumentError, 'redeemables cannot be nil' + end + + if redeemables.length > 5 + fail ArgumentError, 'invalid value for "redeemables", number of items must be less than or equal to 5.' + end + + if redeemables.length < 1 + fail ArgumentError, 'invalid value for "redeemables", number of items must be greater than or equal to 1.' + end + + @redeemables = redeemables + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables == o.redeemables && + order == o.order && + customer == o.customer && + session == o.session && + tracking_id == o.tracking_id && + metadata == o.metadata && + options == o.options + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables, order, customer, session, tracking_id, metadata, options].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_redeem_response_body.rb b/lib/VoucherifySdk/models/redemptions_redeem_response_body.rb new file mode 100644 index 00000000..13aba711 --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_redeem_response_body.rb @@ -0,0 +1,259 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/redemptions`. + class RedemptionsRedeemResponseBody + attr_accessor :redemptions + + attr_accessor :parent_redemption + + attr_accessor :order + + # Lists validation results of each inapplicable redeemable. + attr_accessor :inapplicable_redeemables + + # Lists validation results of each redeemable. If a redeemable can be applied, the API returns `\"status\": \"APPLICABLE\"`. + attr_accessor :skipped_redeemables + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redemptions' => :'redemptions', + :'parent_redemption' => :'parent_redemption', + :'order' => :'order', + :'inapplicable_redeemables' => :'inapplicable_redeemables', + :'skipped_redeemables' => :'skipped_redeemables' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redemptions' => :'Array', + :'parent_redemption' => :'Redemption', + :'order' => :'OrderCalculated', + :'inapplicable_redeemables' => :'Array', + :'skipped_redeemables' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionsRedeemResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionsRedeemResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redemptions') + if (value = attributes[:'redemptions']).is_a?(Array) + self.redemptions = value + end + end + + if attributes.key?(:'parent_redemption') + self.parent_redemption = attributes[:'parent_redemption'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'inapplicable_redeemables') + if (value = attributes[:'inapplicable_redeemables']).is_a?(Array) + self.inapplicable_redeemables = value + end + end + + if attributes.key?(:'skipped_redeemables') + if (value = attributes[:'skipped_redeemables']).is_a?(Array) + self.skipped_redeemables = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redemptions == o.redemptions && + parent_redemption == o.parent_redemption && + order == o.order && + inapplicable_redeemables == o.inapplicable_redeemables && + skipped_redeemables == o.skipped_redeemables + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redemptions, parent_redemption, order, inapplicable_redeemables, skipped_redeemables].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_rollback_create_request_body.rb b/lib/VoucherifySdk/models/redemptions_rollback_create_request_body.rb new file mode 100644 index 00000000..0439c7cb --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_rollback_create_request_body.rb @@ -0,0 +1,254 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/redemptions/{redemptionId}/rollback`. + class RedemptionsRollbackCreateRequestBody + # Reason for the rollback. + attr_accessor :reason + + # Customer's `source_id`. + attr_accessor :tracking_id + + attr_accessor :customer + + attr_accessor :order + + # A set of key/value pairs that you can send in the request body to update **redemption** metadata. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'reason' => :'reason', + :'tracking_id' => :'tracking_id', + :'customer' => :'customer', + :'order' => :'order', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'reason' => :'String', + :'tracking_id' => :'String', + :'customer' => :'Customer', + :'order' => :'Order', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionsRollbackCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionsRollbackCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + reason == o.reason && + tracking_id == o.tracking_id && + customer == o.customer && + order == o.order && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [reason, tracking_id, customer, order, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_rollback_create_response_body.rb b/lib/VoucherifySdk/models/redemptions_rollback_create_response_body.rb new file mode 100644 index 00000000..ce3c93b6 --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_rollback_create_response_body.rb @@ -0,0 +1,588 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/redemptions/{redemptionId}/rollback`. + class RedemptionsRollbackCreateResponseBody + # Unique redemption ID. + attr_accessor :id + + # The type of object represented by the JSON + attr_accessor :object + + # Timestamp representing the date and time when the object was created in ISO 8601 format. + attr_accessor :date + + # Unique customer ID of the redeeming customer. + attr_accessor :customer_id + + # Hashed customer source ID. + attr_accessor :tracking_id + + # The metadata object stores all custom attributes assigned to the redemption. + attr_accessor :metadata + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Unique redemption ID of the parent redemption. + attr_accessor :redemption + + # System generated cause for the redemption being invalid in the context of the provided parameters. + attr_accessor :reason + + # Redemption result. + attr_accessor :result + + # Redemption status. + attr_accessor :status + + attr_accessor :related_redemptions + + # If the result is `FAILURE`, this parameter will provide a generic reason as to why the redemption failed. + attr_accessor :failure_code + + # If the result is `FAILURE`, this parameter will provide a more expanded reason as to why the redemption failed. + attr_accessor :failure_message + + attr_accessor :order + + attr_accessor :channel + + attr_accessor :customer + + # Defines the related object. + attr_accessor :related_object_type + + # Unique related object ID assigned by Voucherify, i.e. v_lfZi4rcEGe0sN9gmnj40bzwK2FH6QUno for a voucher. + attr_accessor :related_object_id + + attr_accessor :voucher + + attr_accessor :promotion_tier + + attr_accessor :reward + + attr_accessor :gift + + attr_accessor :loyalty_card + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'date' => :'date', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'amount' => :'amount', + :'redemption' => :'redemption', + :'reason' => :'reason', + :'result' => :'result', + :'status' => :'status', + :'related_redemptions' => :'related_redemptions', + :'failure_code' => :'failure_code', + :'failure_message' => :'failure_message', + :'order' => :'order', + :'channel' => :'channel', + :'customer' => :'customer', + :'related_object_type' => :'related_object_type', + :'related_object_id' => :'related_object_id', + :'voucher' => :'voucher', + :'promotion_tier' => :'promotion_tier', + :'reward' => :'reward', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'date' => :'Time', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'amount' => :'Integer', + :'redemption' => :'String', + :'reason' => :'String', + :'result' => :'String', + :'status' => :'String', + :'related_redemptions' => :'RedemptionRollbackRelatedRedemptions', + :'failure_code' => :'String', + :'failure_message' => :'String', + :'order' => :'OrderCalculatedNoCustomerData', + :'channel' => :'RedemptionChannel', + :'customer' => :'SimpleCustomer', + :'related_object_type' => :'String', + :'related_object_id' => :'String', + :'voucher' => :'Voucher', + :'promotion_tier' => :'PromotionTier', + :'reward' => :'RedemptionRewardResult', + :'gift' => :'RedemptionGift', + :'loyalty_card' => :'RedemptionLoyaltyCard' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer_id', + :'tracking_id', + :'metadata', + :'redemption', + :'order', + :'customer', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RedemptionRollback' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionsRollbackCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionsRollbackCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'redemption_rollback' + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + else + self.date = nil + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + else + self.customer_id = nil + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + else + self.tracking_id = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + else + self.redemption = nil + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = nil + end + + if attributes.key?(:'related_redemptions') + self.related_redemptions = attributes[:'related_redemptions'] + end + + if attributes.key?(:'failure_code') + self.failure_code = attributes[:'failure_code'] + end + + if attributes.key?(:'failure_message') + self.failure_message = attributes[:'failure_message'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + else + self.order = nil + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = nil + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + else + self.customer = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @date.nil? + invalid_properties.push('invalid value for "date", date cannot be nil.') + end + + if @result.nil? + invalid_properties.push('invalid value for "result", result cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["redemption_rollback"]) + return false unless object_validator.valid?(@object) + return false if @date.nil? + return false if @result.nil? + result_validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + return false unless result_validator.valid?(@result) + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED"]) + return false unless status_validator.valid?(@status) + return false if @channel.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + return false unless related_object_type_validator.valid?(@related_object_type) + return false if @related_object_id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["redemption_rollback"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SUCCEEDED", "FAILED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier", "redemption"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + date == o.date && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + metadata == o.metadata && + amount == o.amount && + redemption == o.redemption && + reason == o.reason && + result == o.result && + status == o.status && + related_redemptions == o.related_redemptions && + failure_code == o.failure_code && + failure_message == o.failure_message && + order == o.order && + channel == o.channel && + customer == o.customer && + related_object_type == o.related_object_type && + related_object_id == o.related_object_id && + voucher == o.voucher && + promotion_tier == o.promotion_tier && + reward == o.reward && + gift == o.gift && + loyalty_card == o.loyalty_card + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, date, customer_id, tracking_id, metadata, amount, redemption, reason, result, status, related_redemptions, failure_code, failure_message, order, channel, customer, related_object_type, related_object_id, voucher, promotion_tier, reward, gift, loyalty_card].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_rollbacks_create_request_body.rb b/lib/VoucherifySdk/models/redemptions_rollbacks_create_request_body.rb new file mode 100644 index 00000000..597974c0 --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_rollbacks_create_request_body.rb @@ -0,0 +1,254 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/redemptions/{parentRedemptionId}/rollbacks`. + class RedemptionsRollbacksCreateRequestBody + # Reason for the rollback. + attr_accessor :reason + + # Customer's `source_id`. + attr_accessor :tracking_id + + attr_accessor :customer + + attr_accessor :order + + # A set of key/value pairs that you can send in the request body to update **redemption** metadata. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'reason' => :'reason', + :'tracking_id' => :'tracking_id', + :'customer' => :'customer', + :'order' => :'order', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'reason' => :'String', + :'tracking_id' => :'String', + :'customer' => :'Customer', + :'order' => :'Order', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionsRollbacksCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionsRollbacksCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + reason == o.reason && + tracking_id == o.tracking_id && + customer == o.customer && + order == o.order && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [reason, tracking_id, customer, order, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/redemptions_rollbacks_create_response_body.rb b/lib/VoucherifySdk/models/redemptions_rollbacks_create_response_body.rb new file mode 100644 index 00000000..5503e64e --- /dev/null +++ b/lib/VoucherifySdk/models/redemptions_rollbacks_create_response_body.rb @@ -0,0 +1,236 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for POST `/redemptions/{parentRedemptionID}/rollbacks`. + class RedemptionsRollbacksCreateResponseBody + # Contains the rollback redemption objects of the particular incentives. + attr_accessor :rollbacks + + attr_accessor :parent_rollback + + attr_accessor :order + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'rollbacks' => :'rollbacks', + :'parent_rollback' => :'parent_rollback', + :'order' => :'order' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'rollbacks' => :'Array', + :'parent_rollback' => :'RedemptionRollback', + :'order' => :'OrderCalculatedNoCustomerData' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RedemptionsRollbacksCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RedemptionsRollbacksCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'rollbacks') + if (value = attributes[:'rollbacks']).is_a?(Array) + self.rollbacks = value + end + end + + if attributes.key?(:'parent_rollback') + self.parent_rollback = attributes[:'parent_rollback'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + rollbacks == o.rollbacks && + parent_rollback == o.parent_rollback && + order == o.order + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [rollbacks, parent_rollback, order].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referral_campaign_voucher.rb b/lib/VoucherifySdk/models/referral_campaign_voucher.rb new file mode 100644 index 00000000..826720eb --- /dev/null +++ b/lib/VoucherifySdk/models/referral_campaign_voucher.rb @@ -0,0 +1,307 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ReferralCampaignVoucher + # Type of voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :code_config + + attr_accessor :redemption + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'discount' => :'discount', + :'code_config' => :'code_config', + :'redemption' => :'redemption', + :'is_referral_code' => :'is_referral_code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'discount' => :'Discount', + :'code_config' => :'CodeConfig', + :'redemption' => :'CampaignLoyaltyVoucherRedemption', + :'is_referral_code' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ReferralCampaignVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ReferralCampaignVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'DISCOUNT_VOUCHER' + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + else + self.discount = nil + end + + if attributes.key?(:'code_config') + self.code_config = attributes[:'code_config'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + else + self.is_referral_code = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @discount.nil? + invalid_properties.push('invalid value for "discount", discount cannot be nil.') + end + + if @is_referral_code.nil? + invalid_properties.push('invalid value for "is_referral_code", is_referral_code cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER"]) + return false unless type_validator.valid?(@type) + return false if @discount.nil? + return false if @is_referral_code.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + discount == o.discount && + code_config == o.code_config && + redemption == o.redemption && + is_referral_code == o.is_referral_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, discount, code_config, redemption, is_referral_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referral_program.rb b/lib/VoucherifySdk/models/referral_program.rb new file mode 100644 index 00000000..618545f1 --- /dev/null +++ b/lib/VoucherifySdk/models/referral_program.rb @@ -0,0 +1,268 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the referee reward and the way a referral is triggered. Context: `REFERRAL_PROGRAM`. + class ReferralProgram + # Define how a referral is triggered. + attr_accessor :conversion_event_type + + attr_accessor :custom_event + + attr_accessor :referee_reward + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conversion_event_type' => :'conversion_event_type', + :'custom_event' => :'custom_event', + :'referee_reward' => :'referee_reward' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conversion_event_type' => :'String', + :'custom_event' => :'ReferralProgramCustomEvent', + :'referee_reward' => :'ReferralProgramRefereeReward' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ReferralProgram` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ReferralProgram`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conversion_event_type') + self.conversion_event_type = attributes[:'conversion_event_type'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'referee_reward') + self.referee_reward = attributes[:'referee_reward'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + conversion_event_type_validator = EnumAttributeValidator.new('String', ["redemption", "custom_event"]) + return false unless conversion_event_type_validator.valid?(@conversion_event_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] conversion_event_type Object to be assigned + def conversion_event_type=(conversion_event_type) + validator = EnumAttributeValidator.new('String', ["redemption", "custom_event"]) + unless validator.valid?(conversion_event_type) + fail ArgumentError, "invalid value for \"conversion_event_type\", must be one of #{validator.allowable_values}." + end + @conversion_event_type = conversion_event_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conversion_event_type == o.conversion_event_type && + custom_event == o.custom_event && + referee_reward == o.referee_reward + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conversion_event_type, custom_event, referee_reward].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referral_program_custom_event.rb b/lib/VoucherifySdk/models/referral_program_custom_event.rb new file mode 100644 index 00000000..3f9daa5c --- /dev/null +++ b/lib/VoucherifySdk/models/referral_program_custom_event.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains details about the custom event. + class ReferralProgramCustomEvent + # Unique custom event ID. + attr_accessor :id + + # Custom event name. + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ReferralProgramCustomEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ReferralProgramCustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referral_program_referee_reward.rb b/lib/VoucherifySdk/models/referral_program_referee_reward.rb new file mode 100644 index 00000000..0d71c213 --- /dev/null +++ b/lib/VoucherifySdk/models/referral_program_referee_reward.rb @@ -0,0 +1,269 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the referee reward. + class ReferralProgramRefereeReward + attr_accessor :related_object_parent + + # Type of reward. + attr_accessor :type + + # Define the number of `points` to add to a loyalty card or `credits` to the balance on a gift card. In case of the gift card, the value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :amount + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'related_object_parent' => :'related_object_parent', + :'type' => :'type', + :'amount' => :'amount' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'related_object_parent' => :'ReferralProgramRefereeRewardRelatedObjectParent', + :'type' => :'String', + :'amount' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ReferralProgramRefereeReward` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ReferralProgramRefereeReward`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'related_object_parent') + self.related_object_parent = attributes[:'related_object_parent'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER", "LOYALTY_CARD", "GIFT_VOUCHER", "LUCKY_DRAW_CODE"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER", "LOYALTY_CARD", "GIFT_VOUCHER", "LUCKY_DRAW_CODE"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + related_object_parent == o.related_object_parent && + type == o.type && + amount == o.amount + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [related_object_parent, type, amount].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referral_program_referee_reward_related_object_parent.rb b/lib/VoucherifySdk/models/referral_program_referee_reward_related_object_parent.rb new file mode 100644 index 00000000..851d4c5f --- /dev/null +++ b/lib/VoucherifySdk/models/referral_program_referee_reward_related_object_parent.rb @@ -0,0 +1,272 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Details of the resource from which the reward originates. + class ReferralProgramRefereeRewardRelatedObjectParent + # Unique ID of the reward source. + attr_accessor :id + + # Name of the reward source. + attr_accessor :name + + # Type of resource represented by the source of the reward. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ReferralProgramRefereeRewardRelatedObjectParent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ReferralProgramRefereeRewardRelatedObjectParent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'CAMPAIGN' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["CAMPAIGN"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["CAMPAIGN"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referrer.rb b/lib/VoucherifySdk/models/referrer.rb new file mode 100644 index 00000000..fd4ca921 --- /dev/null +++ b/lib/VoucherifySdk/models/referrer.rb @@ -0,0 +1,312 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class Referrer + # The ID of an existing customer. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Customer' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Referrer` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Referrer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referrer_id.rb b/lib/VoucherifySdk/models/referrer_id.rb new file mode 100644 index 00000000..541a8252 --- /dev/null +++ b/lib/VoucherifySdk/models/referrer_id.rb @@ -0,0 +1,280 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ReferrerId + # A unique identifier of an existing customer. + attr_accessor :id + + # The type of object represented by JSON. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerId' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ReferrerId` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ReferrerId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/referrer_with_summary_loyalty_referrals.rb b/lib/VoucherifySdk/models/referrer_with_summary_loyalty_referrals.rb new file mode 100644 index 00000000..2d59b229 --- /dev/null +++ b/lib/VoucherifySdk/models/referrer_with_summary_loyalty_referrals.rb @@ -0,0 +1,438 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ReferrerWithSummaryLoyaltyReferrals + # The ID of an existing customer that will be linked to redemption in this request. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + attr_accessor :summary + + attr_accessor :loyalty + + attr_accessor :referrals + + # Object used to store system metadata information. + attr_accessor :system_metadata + + # Timestamp representing the date and time when the customer was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the customer was updated in ISO 8601 format. + attr_accessor :updated_at + + attr_accessor :assets + + # The type of object represented by JSON. + attr_accessor :object + + # Customer's first and last name. + attr_accessor :name + + # An arbitrary string that you can attach to a customer object. + attr_accessor :description + + # Customer's email address. + attr_accessor :email + + # Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel. + attr_accessor :phone + + # *Deprecated* Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthday + + # Customer's birthdate; format YYYY-MM-DD. + attr_accessor :birthdate + + attr_accessor :address + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'summary' => :'summary', + :'loyalty' => :'loyalty', + :'referrals' => :'referrals', + :'system_metadata' => :'system_metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assets' => :'assets', + :'object' => :'object', + :'name' => :'name', + :'description' => :'description', + :'email' => :'email', + :'phone' => :'phone', + :'birthday' => :'birthday', + :'birthdate' => :'birthdate', + :'address' => :'address', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'summary' => :'CustomerSummary', + :'loyalty' => :'CustomerLoyalty', + :'referrals' => :'CustomerReferrals', + :'system_metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assets' => :'CustomerResponseDataAssets', + :'object' => :'String', + :'name' => :'String', + :'description' => :'String', + :'email' => :'String', + :'phone' => :'String', + :'birthday' => :'Date', + :'birthdate' => :'Date', + :'address' => :'CustomerBaseAddress', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'summary', + :'loyalty', + :'referrals', + :'address', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'CustomerWithSummaryLoyaltyReferrals' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ReferrerWithSummaryLoyaltyReferrals` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ReferrerWithSummaryLoyaltyReferrals`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'summary') + self.summary = attributes[:'summary'] + else + self.summary = nil + end + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + + if attributes.key?(:'referrals') + self.referrals = attributes[:'referrals'] + else + self.referrals = nil + end + + if attributes.key?(:'system_metadata') + self.system_metadata = attributes[:'system_metadata'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.key?(:'birthday') + self.birthday = attributes[:'birthday'] + end + + if attributes.key?(:'birthdate') + self.birthdate = attributes[:'birthdate'] + end + + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + summary == o.summary && + loyalty == o.loyalty && + referrals == o.referrals && + system_metadata == o.system_metadata && + created_at == o.created_at && + updated_at == o.updated_at && + assets == o.assets && + object == o.object && + name == o.name && + description == o.description && + email == o.email && + phone == o.phone && + birthday == o.birthday && + birthdate == o.birthdate && + address == o.address && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, summary, loyalty, referrals, system_metadata, created_at, updated_at, assets, object, name, description, email, phone, birthday, birthdate, address, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/resource_types.rb b/lib/VoucherifySdk/models/resource_types.rb new file mode 100644 index 00000000..1d88d3ca --- /dev/null +++ b/lib/VoucherifySdk/models/resource_types.rb @@ -0,0 +1,41 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ResourceTypes + CAMPAIGN = "campaign".freeze + VOUCHER = "voucher".freeze + PROMOTION_TIER = "promotion_tier".freeze + + def self.all_vars + @all_vars ||= [CAMPAIGN, VOUCHER, PROMOTION_TIER].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ResourceTypes.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ResourceTypes" + end + end +end diff --git a/lib/VoucherifySdk/models/reward.rb b/lib/VoucherifySdk/models/reward.rb new file mode 100644 index 00000000..fad59756 --- /dev/null +++ b/lib/VoucherifySdk/models/reward.rb @@ -0,0 +1,410 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class Reward + # Unique reward ID, assigned by Voucherify. + attr_accessor :id + + # Reward name. + attr_accessor :name + + # Configurable for **material rewards**. The number of units of the product that you want to share as reward. + attr_accessor :stock + + # Defines the number of already invoked (successful) reward redemptions. + attr_accessor :redeemed + + attr_accessor :attributes + + # The metadata object stores all custom attributes assigned to the reward. A set of key/value pairs that you can attach to a reward object. It can be useful for storing additional information about the reward in a structured format. + attr_accessor :metadata + + # Reward type. + attr_accessor :type + + attr_accessor :parameters + + # Timestamp representing the date and time when the reward was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'stock' => :'stock', + :'redeemed' => :'redeemed', + :'attributes' => :'attributes', + :'metadata' => :'metadata', + :'type' => :'type', + :'parameters' => :'parameters', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'stock' => :'Integer', + :'redeemed' => :'Integer', + :'attributes' => :'RewardAttributes', + :'metadata' => :'Object', + :'type' => :'String', + :'parameters' => :'RewardType', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'stock', + :'redeemed', + :'updated_at', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Reward` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Reward`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'stock') + self.stock = attributes[:'stock'] + else + self.stock = nil + end + + if attributes.key?(:'redeemed') + self.redeemed = attributes[:'redeemed'] + else + self.redeemed = nil + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @metadata.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + return false unless type_validator.valid?(@type) + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + stock == o.stock && + redeemed == o.redeemed && + attributes == o.attributes && + metadata == o.metadata && + type == o.type && + parameters == o.parameters && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, stock, redeemed, attributes, metadata, type, parameters, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignment.rb b/lib/VoucherifySdk/models/reward_assignment.rb new file mode 100644 index 00000000..41bf3e22 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignment.rb @@ -0,0 +1,383 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RewardAssignment + # Unique reward assignment ID, assigned by Voucherify. + attr_accessor :id + + # Associated reward ID. + attr_accessor :reward_id + + # Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward assignment. + attr_accessor :object + + # Related object ID to which the reward was assigned. + attr_accessor :related_object_id + + # Related object type to which the reward was assigned. + attr_accessor :related_object_type + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'reward_id' => :'reward_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'reward_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'parameters' => :'RewardAssignmentParametersParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RewardAssignmentBase', + :'RewardAssignmentParameters' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignment` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward_id') + self.reward_id = attributes[:'reward_id'] + else + self.reward_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward_assignment' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'campaign' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @reward_id.nil? + invalid_properties.push('invalid value for "reward_id", reward_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @reward_id.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + return false unless object_validator.valid?(@object) + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + reward_id == o.reward_id && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, reward_id, created_at, updated_at, object, related_object_id, related_object_type, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignment_base.rb b/lib/VoucherifySdk/models/reward_assignment_base.rb new file mode 100644 index 00000000..bdb39012 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignment_base.rb @@ -0,0 +1,366 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RewardAssignmentBase + # Unique reward assignment ID, assigned by Voucherify. + attr_accessor :id + + # Associated reward ID. + attr_accessor :reward_id + + # Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward assignment. + attr_accessor :object + + # Related object ID to which the reward was assigned. + attr_accessor :related_object_id + + # Related object type to which the reward was assigned. + attr_accessor :related_object_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'reward_id' => :'reward_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'reward_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward_id') + self.reward_id = attributes[:'reward_id'] + else + self.reward_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward_assignment' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'campaign' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @reward_id.nil? + invalid_properties.push('invalid value for "reward_id", reward_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @reward_id.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + return false unless object_validator.valid?(@object) + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + reward_id == o.reward_id && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, reward_id, created_at, updated_at, object, related_object_id, related_object_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignment_parameters.rb b/lib/VoucherifySdk/models/reward_assignment_parameters.rb new file mode 100644 index 00000000..d3bacd29 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignment_parameters.rb @@ -0,0 +1,214 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RewardAssignmentParameters + attr_accessor :parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'parameters' => :'RewardAssignmentParametersParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignment_parameters_parameters.rb b/lib/VoucherifySdk/models/reward_assignment_parameters_parameters.rb new file mode 100644 index 00000000..a39ca6a6 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignment_parameters_parameters.rb @@ -0,0 +1,222 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the cost of the reward. + class RewardAssignmentParametersParameters + attr_accessor :loyalty + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'loyalty' => :'loyalty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'loyalty' => :'RewardAssignmentParametersParametersLoyalty' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentParametersParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentParametersParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + loyalty == o.loyalty + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [loyalty].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignment_parameters_parameters_loyalty.rb b/lib/VoucherifySdk/models/reward_assignment_parameters_parameters_loyalty.rb new file mode 100644 index 00000000..926d7098 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignment_parameters_parameters_loyalty.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the equivalent points value of the reward. + class RewardAssignmentParametersParametersLoyalty + # The number of points required to redeem the reward. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentParametersParametersLoyalty` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentParametersParametersLoyalty`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignments_create_coin_reward_request_body.rb b/lib/VoucherifySdk/models/reward_assignments_create_coin_reward_request_body.rb new file mode 100644 index 00000000..75e7cad2 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignments_create_coin_reward_request_body.rb @@ -0,0 +1,234 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/rewards/{rewardID}/assignments`. + class RewardAssignmentsCreateCoinRewardRequestBody + # The campaign ID of the campaign to which the reward is to be assigned. + attr_accessor :campaign + + attr_accessor :validation_rules + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'campaign' => :'campaign', + :'validation_rules' => :'validation_rules' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'campaign' => :'String', + :'validation_rules' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentsCreateCoinRewardRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentsCreateCoinRewardRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + else + self.campaign = nil + end + + if attributes.key?(:'validation_rules') + if (value = attributes[:'validation_rules']).is_a?(Array) + self.validation_rules = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @campaign.nil? + invalid_properties.push('invalid value for "campaign", campaign cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @campaign.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + campaign == o.campaign && + validation_rules == o.validation_rules + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [campaign, validation_rules].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body.rb b/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body.rb new file mode 100644 index 00000000..13140dfb --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body.rb @@ -0,0 +1,239 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/rewards/{rewardID}/assignments`. + class RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody + # The campaign ID of the campaign to which the reward is to be assigned. + attr_accessor :campaign + + attr_accessor :parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'campaign' => :'campaign', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'campaign' => :'String', + :'parameters' => :'RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + else + self.campaign = nil + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + else + self.parameters = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @campaign.nil? + invalid_properties.push('invalid value for "campaign", campaign cannot be nil.') + end + + if @parameters.nil? + invalid_properties.push('invalid value for "parameters", parameters cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @campaign.nil? + return false if @parameters.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + campaign == o.campaign && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [campaign, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters.rb b/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters.rb new file mode 100644 index 00000000..1160bd37 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters.rb @@ -0,0 +1,222 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the cost of the reward. + class RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters + attr_accessor :loyalty + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'loyalty' => :'loyalty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'loyalty' => :'RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + else + self.loyalty = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @loyalty.nil? + invalid_properties.push('invalid value for "loyalty", loyalty cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @loyalty.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + loyalty == o.loyalty + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [loyalty].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters_loyalty.rb b/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters_loyalty.rb new file mode 100644 index 00000000..a4ce4a52 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_assignments_create_digital_or_material_reward_request_body_parameters_loyalty.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the equivalent points value of the reward. + class RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty + # Number of points that will be subtracted from the loyalty card points balance if the reward is redeemed. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAssignmentsCreateDigitalOrMaterialRewardRequestBodyParametersLoyalty`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_attributes.rb b/lib/VoucherifySdk/models/reward_attributes.rb new file mode 100644 index 00000000..15ce1c86 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_attributes.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # These properties are configurable for **material rewards**. + class RewardAttributes + # The HTTPS URL pointing to the .png or .jpg file. + attr_accessor :image_url + + # An arbitrary string that you can attach to a material reward. + attr_accessor :description + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'image_url' => :'image_url', + :'description' => :'description' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'image_url' => :'String', + :'description' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardAttributes` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + image_url == o.image_url && + description == o.description + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [image_url, description].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_type.rb b/lib/VoucherifySdk/models/reward_type.rb new file mode 100644 index 00000000..1bdc624d --- /dev/null +++ b/lib/VoucherifySdk/models/reward_type.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module RewardType + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'RewardTypeCampaign', + :'RewardTypeCoin', + :'RewardTypeMaterial' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/reward_type_campaign.rb b/lib/VoucherifySdk/models/reward_type_campaign.rb new file mode 100644 index 00000000..e94a811d --- /dev/null +++ b/lib/VoucherifySdk/models/reward_type_campaign.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RewardTypeCampaign + attr_accessor :campaign + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'campaign' => :'campaign' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'campaign' => :'RewardTypeCampaignCampaign' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardTypeCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardTypeCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + else + self.campaign = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @campaign.nil? + invalid_properties.push('invalid value for "campaign", campaign cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @campaign.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + campaign == o.campaign + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [campaign].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_type_campaign_campaign.rb b/lib/VoucherifySdk/models/reward_type_campaign_campaign.rb new file mode 100644 index 00000000..948b97d4 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_type_campaign_campaign.rb @@ -0,0 +1,284 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Objects stores information about the campaign related to the reward. + class RewardTypeCampaignCampaign + # Unique campaign ID, assigned by Voucherify. + attr_accessor :id + + # The incremental amout to be added to the current balance on the gift card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :balance + + # Campaign type. + attr_accessor :type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'balance' => :'balance', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'balance' => :'Integer', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardTypeCampaignCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardTypeCampaignCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_COUPONS", "PROMOTION", "GIFT_VOUCHERS", "REFERRAL_PROGRAM", "LOYALTY_PROGRAM"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["DISCOUNT_COUPONS", "PROMOTION", "GIFT_VOUCHERS", "REFERRAL_PROGRAM", "LOYALTY_PROGRAM"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + balance == o.balance && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, balance, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_type_coin.rb b/lib/VoucherifySdk/models/reward_type_coin.rb new file mode 100644 index 00000000..11b17de0 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_type_coin.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RewardTypeCoin + attr_accessor :coin + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'coin' => :'coin' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'coin' => :'RewardTypeCoinCoin' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardTypeCoin` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardTypeCoin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'coin') + self.coin = attributes[:'coin'] + else + self.coin = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @coin.nil? + invalid_properties.push('invalid value for "coin", coin cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @coin.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + coin == o.coin + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [coin].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_type_coin_coin.rb b/lib/VoucherifySdk/models/reward_type_coin_coin.rb new file mode 100644 index 00000000..cf9d077e --- /dev/null +++ b/lib/VoucherifySdk/models/reward_type_coin_coin.rb @@ -0,0 +1,233 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the ratio by mapping the number of loyalty points in points_ratio to a predefined cash amount in exchange_ratio. + class RewardTypeCoinCoin + # The cash equivalent of the points defined in the points_ratio property. + attr_accessor :exchange_ratio + + # The number of loyalty points that will map to the predefined cash amount defined by the exchange_ratio property. + attr_accessor :points_ratio + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'exchange_ratio' => :'exchange_ratio', + :'points_ratio' => :'points_ratio' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'exchange_ratio' => :'Float', + :'points_ratio' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardTypeCoinCoin` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardTypeCoinCoin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'exchange_ratio') + self.exchange_ratio = attributes[:'exchange_ratio'] + else + self.exchange_ratio = nil + end + + if attributes.key?(:'points_ratio') + self.points_ratio = attributes[:'points_ratio'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @exchange_ratio.nil? + invalid_properties.push('invalid value for "exchange_ratio", exchange_ratio cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @exchange_ratio.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + exchange_ratio == o.exchange_ratio && + points_ratio == o.points_ratio + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [exchange_ratio, points_ratio].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_type_material.rb b/lib/VoucherifySdk/models/reward_type_material.rb new file mode 100644 index 00000000..7975d8e0 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_type_material.rb @@ -0,0 +1,221 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class RewardTypeMaterial + attr_accessor :product + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'product' => :'product' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'product' => :'RewardTypeMaterialProduct' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardTypeMaterial` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardTypeMaterial`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'product') + self.product = attributes[:'product'] + else + self.product = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @product.nil? + invalid_properties.push('invalid value for "product", product cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @product.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + product == o.product + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [product].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/reward_type_material_product.rb b/lib/VoucherifySdk/models/reward_type_material_product.rb new file mode 100644 index 00000000..5ff1f8d5 --- /dev/null +++ b/lib/VoucherifySdk/models/reward_type_material_product.rb @@ -0,0 +1,236 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the product given as a reward. + class RewardTypeMaterialProduct + # Unique product ID, assigned by Voucherify. + attr_accessor :id + + # Unique SKU ID, assigned by Voucherify, of the SKU given as a reward. + attr_accessor :sku_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'sku_id' => :'sku_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'sku_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'sku_id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardTypeMaterialProduct` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardTypeMaterialProduct`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'sku_id') + self.sku_id = attributes[:'sku_id'] + else + self.sku_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + sku_id == o.sku_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, sku_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_create_request_body.rb b/lib/VoucherifySdk/models/rewards_assignments_create_request_body.rb new file mode 100644 index 00000000..3c8ac1fa --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_create_request_body.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/rewards/{rewardID}/assignments`. + module RewardsAssignmentsCreateRequestBody + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'RewardAssignmentsCreateCoinRewardRequestBody', + :'RewardAssignmentsCreateDigitalOrMaterialRewardRequestBody' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_create_response_body.rb b/lib/VoucherifySdk/models/rewards_assignments_create_response_body.rb new file mode 100644 index 00000000..d3d08d3d --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_create_response_body.rb @@ -0,0 +1,383 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/rewards/{rewardId}/assignments/{assignmentId}`. + class RewardsAssignmentsCreateResponseBody + # Unique reward assignment ID, assigned by Voucherify. + attr_accessor :id + + # Associated reward ID. + attr_accessor :reward_id + + # Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward assignment. + attr_accessor :object + + # Related object ID to which the reward was assigned. + attr_accessor :related_object_id + + # Related object type to which the reward was assigned. + attr_accessor :related_object_type + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'reward_id' => :'reward_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'reward_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'parameters' => :'RewardAssignmentParametersParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RewardAssignment' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardsAssignmentsCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardsAssignmentsCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward_id') + self.reward_id = attributes[:'reward_id'] + else + self.reward_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward_assignment' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'campaign' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @reward_id.nil? + invalid_properties.push('invalid value for "reward_id", reward_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @reward_id.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + return false unless object_validator.valid?(@object) + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + reward_id == o.reward_id && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, reward_id, created_at, updated_at, object, related_object_id, related_object_type, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_get_response_body.rb b/lib/VoucherifySdk/models/rewards_assignments_get_response_body.rb new file mode 100644 index 00000000..ca265766 --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_get_response_body.rb @@ -0,0 +1,383 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/rewards/{rewardId}/assignments/{assignmentId}`. + class RewardsAssignmentsGetResponseBody + # Unique reward assignment ID, assigned by Voucherify. + attr_accessor :id + + # Associated reward ID. + attr_accessor :reward_id + + # Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward assignment. + attr_accessor :object + + # Related object ID to which the reward was assigned. + attr_accessor :related_object_id + + # Related object type to which the reward was assigned. + attr_accessor :related_object_type + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'reward_id' => :'reward_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'reward_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'parameters' => :'RewardAssignmentParametersParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RewardAssignment' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardsAssignmentsGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardsAssignmentsGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward_id') + self.reward_id = attributes[:'reward_id'] + else + self.reward_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward_assignment' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'campaign' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @reward_id.nil? + invalid_properties.push('invalid value for "reward_id", reward_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @reward_id.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + return false unless object_validator.valid?(@object) + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + reward_id == o.reward_id && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, reward_id, created_at, updated_at, object, related_object_id, related_object_type, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_list_response_body.rb b/lib/VoucherifySdk/models/rewards_assignments_list_response_body.rb new file mode 100644 index 00000000..9633e2ec --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_list_response_body.rb @@ -0,0 +1,275 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/rewards/{rewardID}/assignments`. + class RewardsAssignmentsListResponseBody + # The type of object represented by JSON. This object stores information about reward assignments in a dictionary. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of reward assignments. + attr_accessor :data_ref + + attr_accessor :data + + # Total number of reward assignments. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardsAssignmentsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardsAssignmentsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_update_request_body.rb b/lib/VoucherifySdk/models/rewards_assignments_update_request_body.rb new file mode 100644 index 00000000..e2839efc --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_update_request_body.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **PUT** `/loyalties/{campaignId}/rewards/{assignmentId}` and **PUT** `/rewards/{rewardId}/assignments/{assignmentId}`. + class RewardsAssignmentsUpdateRequestBody + attr_accessor :parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'parameters' => :'RewardsAssignmentsUpdateRequestBodyParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardsAssignmentsUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardsAssignmentsUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_update_request_body_parameters.rb b/lib/VoucherifySdk/models/rewards_assignments_update_request_body_parameters.rb new file mode 100644 index 00000000..fcd75dd2 --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_update_request_body_parameters.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # An object that defines the price of the reward in loyalty points. + class RewardsAssignmentsUpdateRequestBodyParameters + attr_accessor :loyalty + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'loyalty' => :'loyalty' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'loyalty' => :'RewardsAssignmentsUpdateRequestBodyParametersLoyalty' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'loyalty') + self.loyalty = attributes[:'loyalty'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + loyalty == o.loyalty + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [loyalty].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_update_request_body_parameters_loyalty.rb b/lib/VoucherifySdk/models/rewards_assignments_update_request_body_parameters_loyalty.rb new file mode 100644 index 00000000..a4a17a06 --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_update_request_body_parameters_loyalty.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores the points parameter. + class RewardsAssignmentsUpdateRequestBodyParametersLoyalty + # Defines how many points are required to obtain the reward. + attr_accessor :points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParametersLoyalty` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardsAssignmentsUpdateRequestBodyParametersLoyalty`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/rewards_assignments_update_response_body.rb b/lib/VoucherifySdk/models/rewards_assignments_update_response_body.rb new file mode 100644 index 00000000..a8ebe7d2 --- /dev/null +++ b/lib/VoucherifySdk/models/rewards_assignments_update_response_body.rb @@ -0,0 +1,383 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/rewards/{rewardId}/assignments/{assignmentId}`. + class RewardsAssignmentsUpdateResponseBody + # Unique reward assignment ID, assigned by Voucherify. + attr_accessor :id + + # Associated reward ID. + attr_accessor :reward_id + + # Timestamp representing the date and time when the reward assignment was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward assignment was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by the JSON. This object stores information about the reward assignment. + attr_accessor :object + + # Related object ID to which the reward was assigned. + attr_accessor :related_object_id + + # Related object type to which the reward was assigned. + attr_accessor :related_object_type + + attr_accessor :parameters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'reward_id' => :'reward_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'reward_id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'parameters' => :'RewardAssignmentParametersParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'RewardAssignment' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::RewardsAssignmentsUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::RewardsAssignmentsUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'reward_id') + self.reward_id = attributes[:'reward_id'] + else + self.reward_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward_assignment' + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = 'campaign' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @reward_id.nil? + invalid_properties.push('invalid value for "reward_id", reward_id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @reward_id.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + return false unless object_validator.valid?(@object) + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless related_object_type_validator.valid?(@related_object_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + reward_id == o.reward_id && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, reward_id, created_at, updated_at, object, related_object_id, related_object_type, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/schema_that_contains_unique_properties_for_promotion_campaign_promotion.rb b/lib/VoucherifySdk/models/schema_that_contains_unique_properties_for_promotion_campaign_promotion.rb new file mode 100644 index 00000000..1257eb55 --- /dev/null +++ b/lib/VoucherifySdk/models/schema_that_contains_unique_properties_for_promotion_campaign_promotion.rb @@ -0,0 +1,217 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion + attr_accessor :tiers + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tiers' => :'tiers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'tiers' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'tiers' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SchemaThatContainsUniquePropertiesForPromotionCampaignPromotion`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'tiers') + if (value = attributes[:'tiers']).is_a?(Array) + self.tiers = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + tiers == o.tiers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [tiers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/session.rb b/lib/VoucherifySdk/models/session.rb new file mode 100644 index 00000000..e0d5f8cf --- /dev/null +++ b/lib/VoucherifySdk/models/session.rb @@ -0,0 +1,307 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class Session + # The session unique ID assigned by Voucherify or your own unique session ID. Sending an existing ID will result in overwriting an existing session. If no session key is provided, then a new ID will be generated. + attr_accessor :key + + # This parameter is required to establish a new session. The session locks the redemption quantity by 1. + attr_accessor :type + + # Value for the period of time that the session is active. Units for this parameter are defined by the session.ttl_unit parameter. + attr_accessor :ttl + + # Defines the type of unit in which the session time is counted. + attr_accessor :ttl_unit + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'key' => :'key', + :'type' => :'type', + :'ttl' => :'ttl', + :'ttl_unit' => :'ttl_unit' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'key' => :'String', + :'type' => :'String', + :'ttl' => :'Float', + :'ttl_unit' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Session` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Session`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'key') + self.key = attributes[:'key'] + else + self.key = 'LOCK' + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'LOCK' + end + + if attributes.key?(:'ttl') + self.ttl = attributes[:'ttl'] + end + + if attributes.key?(:'ttl_unit') + self.ttl_unit = attributes[:'ttl_unit'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + key_validator = EnumAttributeValidator.new('String', ["LOCK"]) + return false unless key_validator.valid?(@key) + type_validator = EnumAttributeValidator.new('String', ["LOCK"]) + return false unless type_validator.valid?(@type) + ttl_unit_validator = EnumAttributeValidator.new('String', ["DAYS", "HOURS", "MICROSECONDS", "MILLISECONDS", "MINUTES", "NANOSECONDS", "SECONDS"]) + return false unless ttl_unit_validator.valid?(@ttl_unit) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] key Object to be assigned + def key=(key) + validator = EnumAttributeValidator.new('String', ["LOCK"]) + unless validator.valid?(key) + fail ArgumentError, "invalid value for \"key\", must be one of #{validator.allowable_values}." + end + @key = key + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["LOCK"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] ttl_unit Object to be assigned + def ttl_unit=(ttl_unit) + validator = EnumAttributeValidator.new('String', ["DAYS", "HOURS", "MICROSECONDS", "MILLISECONDS", "MINUTES", "NANOSECONDS", "SECONDS"]) + unless validator.valid?(ttl_unit) + fail ArgumentError, "invalid value for \"ttl_unit\", must be one of #{validator.allowable_values}." + end + @ttl_unit = ttl_unit + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + key == o.key && + type == o.type && + ttl == o.ttl && + ttl_unit == o.ttl_unit + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [key, type, ttl, ttl_unit].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_campaign.rb b/lib/VoucherifySdk/models/simple_campaign.rb new file mode 100644 index 00000000..33fedfd2 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_campaign.rb @@ -0,0 +1,381 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for creating a discount voucher campaign using **POST** `/campaigns`. + class SimpleCampaign + # Campaign name. + attr_accessor :id + + # Campaign name. + attr_accessor :name + + # Type of campaign. + attr_accessor :campaign_type + + # Defines whether the campaign can be updated with new vouchers after campaign creation. - `AUTO_UPDATE`: By choosing the auto update option you will create a campaign that can be enhanced by new vouchers after the time of creation (e.g. by publish vouchers method). - `STATIC`: vouchers need to be manually published. + attr_accessor :type + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + attr_accessor :voucher + + attr_accessor :lucky_draw + + attr_accessor :referral_program + + # Indicates whether customers will be able to auto-join a loyalty campaign if any earning rule is fulfilled. + attr_accessor :auto_join + + # If this value is set to `true`, customers will be able to join the campaign only once. + attr_accessor :join_once + + # Indicates whether campaign is active + attr_accessor :active + + # Timestamp representing the date and time when the campaign was created in ISO 8601 format. + attr_accessor :created_at + + # The type of object represented by JSON. This object stores information about the campaign. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'campaign_type' => :'campaign_type', + :'type' => :'type', + :'is_referral_code' => :'is_referral_code', + :'voucher' => :'voucher', + :'lucky_draw' => :'lucky_draw', + :'referral_program' => :'referral_program', + :'auto_join' => :'auto_join', + :'join_once' => :'join_once', + :'active' => :'active', + :'created_at' => :'created_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'campaign_type' => :'String', + :'type' => :'String', + :'is_referral_code' => :'Boolean', + :'voucher' => :'Object', + :'lucky_draw' => :'Object', + :'referral_program' => :'ReferralProgram', + :'auto_join' => :'Boolean', + :'join_once' => :'Boolean', + :'active' => :'Boolean', + :'created_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'campaign_type') + self.campaign_type = attributes[:'campaign_type'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'lucky_draw') + self.lucky_draw = attributes[:'lucky_draw'] + end + + if attributes.key?(:'referral_program') + self.referral_program = attributes[:'referral_program'] + end + + if attributes.key?(:'auto_join') + self.auto_join = attributes[:'auto_join'] + end + + if attributes.key?(:'join_once') + self.join_once = attributes[:'join_once'] + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'campaign' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + return false unless type_validator.valid?(@type) + object_validator = EnumAttributeValidator.new('String', ["campaign"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["AUTO_UPDATE", "STATIC"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["campaign"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + campaign_type == o.campaign_type && + type == o.type && + is_referral_code == o.is_referral_code && + voucher == o.voucher && + lucky_draw == o.lucky_draw && + referral_program == o.referral_program && + auto_join == o.auto_join && + join_once == o.join_once && + active == o.active && + created_at == o.created_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, campaign_type, type, is_referral_code, voucher, lucky_draw, referral_program, auto_join, join_once, active, created_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_consent.rb b/lib/VoucherifySdk/models/simple_consent.rb new file mode 100644 index 00000000..74128390 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_consent.rb @@ -0,0 +1,273 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleConsent + attr_accessor :id + + attr_accessor :name + + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleConsent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleConsent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'consent' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["consent"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["consent"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_customer.rb b/lib/VoucherifySdk/models/simple_customer.rb new file mode 100644 index 00000000..a1b0a4ab --- /dev/null +++ b/lib/VoucherifySdk/models/simple_customer.rb @@ -0,0 +1,301 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleCustomer + # The ID of an existing customer that will be linked to redemption in this request. + attr_accessor :id + + # A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored. + attr_accessor :source_id + + # Customer's first and last name. + attr_accessor :name + + # Customer's email address. + attr_accessor :email + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # The type of object represented by JSON. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'email' => :'email', + :'metadata' => :'metadata', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'email' => :'String', + :'metadata' => :'Object', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleCustomer` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleCustomer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["customer"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["customer"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + email == o.email && + metadata == o.metadata && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, email, metadata, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_customer_required_object_type.rb b/lib/VoucherifySdk/models/simple_customer_required_object_type.rb new file mode 100644 index 00000000..0b0adf0e --- /dev/null +++ b/lib/VoucherifySdk/models/simple_customer_required_object_type.rb @@ -0,0 +1,273 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a customer with limited properties used in Event Tracking endpoints. + class SimpleCustomerRequiredObjectType + # The unique ID of a customer that is assigned by Voucherify. + attr_accessor :id + + # The merchant’s customer ID if it is different from the Voucherify customer ID. It is really useful in case of an integration between multiple systems. It can be a customer ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + # Customer's first and last name. + attr_accessor :name + + # Customer's email address. + attr_accessor :email + + # A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments. + attr_accessor :metadata + + # The type of object represented by the JSON. This object stores information about the customer. + attr_accessor :object + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name', + :'email' => :'email', + :'metadata' => :'metadata', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String', + :'email' => :'String', + :'metadata' => :'Object', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleCustomerRequiredObjectType` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleCustomerRequiredObjectType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'customer' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name && + email == o.email && + metadata == o.metadata && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name, email, metadata, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_order.rb b/lib/VoucherifySdk/models/simple_order.rb new file mode 100644 index 00000000..ad9cf2ec --- /dev/null +++ b/lib/VoucherifySdk/models/simple_order.rb @@ -0,0 +1,423 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Order information. + class SimpleOrder + # Unique ID assigned by Voucherify of an existing order that will be linked to the redemption of this request. + attr_accessor :id + + # Unique source ID of an existing order that will be linked to the redemption of this request. + attr_accessor :source_id + + # The order status. + attr_accessor :status + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + # Sum of all order-level discounts applied to the order. + attr_accessor :discount_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Sum of all product-specific discounts applied to the order. + attr_accessor :items_discount_amount + + # Sum of all product-specific discounts applied in a particular request. `sum(items, i => i.applied_discount_amount)` + attr_accessor :items_applied_discount_amount + + # Sum of all order-level AND all product-specific discounts applied to the order. + attr_accessor :total_discount_amount + + # Sum of all order-level AND all product-specific discounts applied in a particular request. `total_applied_discount_amount` = `applied_discount_amount` + `items_applied_discount_amount` + attr_accessor :total_applied_discount_amount + + # Order amount after undoing all the discounts through the rollback redemption. + attr_accessor :total_amount + + # Array of items applied to the order. + attr_accessor :items + + # A set of custom key/value pairs that you can attach to an order. It can be useful for storing additional information about the order in a structured format. + attr_accessor :metadata + + # The type of object represented by JSON. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'status' => :'status', + :'customer_id' => :'customer_id', + :'referrer_id' => :'referrer_id', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'items_discount_amount' => :'items_discount_amount', + :'items_applied_discount_amount' => :'items_applied_discount_amount', + :'total_discount_amount' => :'total_discount_amount', + :'total_applied_discount_amount' => :'total_applied_discount_amount', + :'total_amount' => :'total_amount', + :'items' => :'items', + :'metadata' => :'metadata', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'status' => :'String', + :'customer_id' => :'String', + :'referrer_id' => :'String', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'items_discount_amount' => :'Integer', + :'items_applied_discount_amount' => :'Integer', + :'total_discount_amount' => :'Integer', + :'total_applied_discount_amount' => :'Integer', + :'total_amount' => :'Integer', + :'items' => :'Array', + :'metadata' => :'Object', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer_id', + :'referrer_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleOrder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'items_discount_amount') + self.items_discount_amount = attributes[:'items_discount_amount'] + end + + if attributes.key?(:'items_applied_discount_amount') + self.items_applied_discount_amount = attributes[:'items_applied_discount_amount'] + end + + if attributes.key?(:'total_discount_amount') + self.total_discount_amount = attributes[:'total_discount_amount'] + end + + if attributes.key?(:'total_applied_discount_amount') + self.total_applied_discount_amount = attributes[:'total_applied_discount_amount'] + end + + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + end + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + return false unless status_validator.valid?(@status) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["order"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["CREATED", "PAID", "CANCELED", "FULFILLED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + status == o.status && + customer_id == o.customer_id && + referrer_id == o.referrer_id && + amount == o.amount && + discount_amount == o.discount_amount && + applied_discount_amount == o.applied_discount_amount && + items_discount_amount == o.items_discount_amount && + items_applied_discount_amount == o.items_applied_discount_amount && + total_discount_amount == o.total_discount_amount && + total_applied_discount_amount == o.total_applied_discount_amount && + total_amount == o.total_amount && + items == o.items && + metadata == o.metadata && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, status, customer_id, referrer_id, amount, discount_amount, applied_discount_amount, items_discount_amount, items_applied_discount_amount, total_discount_amount, total_applied_discount_amount, total_amount, items, metadata, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_order_item.rb b/lib/VoucherifySdk/models/simple_order_item.rb new file mode 100644 index 00000000..6669c54f --- /dev/null +++ b/lib/VoucherifySdk/models/simple_order_item.rb @@ -0,0 +1,363 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleOrderItem + # The type of object represented by JSON. This object stores information about the `order_item`. + attr_accessor :object + + # The merchant’s product/SKU ID (if it is different from the Voucherify product/SKU ID). It is useful in the integration between multiple systems. It can be an ID from an eCommerce site, a database, or a third-party service. + attr_accessor :source_id + + # Used along with the source_id property, can be set to either sku or product. + attr_accessor :related_object + + # A unique product ID assigned by Voucherify. + attr_accessor :product_id + + # A unique SKU ID assigned by Voucherify. + attr_accessor :sku_id + + # The quantity of the particular item in the cart. + attr_accessor :quantity + + # Number of dicounted items. + attr_accessor :discount_quantity + + # The total amount of the order item (price * quantity). + attr_accessor :amount + + # Sum of all order-item-level discounts applied to the order. + attr_accessor :discount_amount + + # This field shows the order-level discount applied. + attr_accessor :applied_discount_amount + + # Unit price of an item. Value is multiplied by 100 to precisely represent 2 decimal places. For example `10000 cents` for `$100.00`. + attr_accessor :price + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'source_id' => :'source_id', + :'related_object' => :'related_object', + :'product_id' => :'product_id', + :'sku_id' => :'sku_id', + :'quantity' => :'quantity', + :'discount_quantity' => :'discount_quantity', + :'amount' => :'amount', + :'discount_amount' => :'discount_amount', + :'applied_discount_amount' => :'applied_discount_amount', + :'price' => :'price' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'source_id' => :'String', + :'related_object' => :'String', + :'product_id' => :'String', + :'sku_id' => :'String', + :'quantity' => :'Integer', + :'discount_quantity' => :'Integer', + :'amount' => :'Integer', + :'discount_amount' => :'Integer', + :'applied_discount_amount' => :'Integer', + :'price' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleOrderItem` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleOrderItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'order_item' + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'related_object') + self.related_object = attributes[:'related_object'] + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + end + + if attributes.key?(:'sku_id') + self.sku_id = attributes[:'sku_id'] + end + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + + if attributes.key?(:'discount_quantity') + self.discount_quantity = attributes[:'discount_quantity'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'discount_amount') + self.discount_amount = attributes[:'discount_amount'] + end + + if attributes.key?(:'applied_discount_amount') + self.applied_discount_amount = attributes[:'applied_discount_amount'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["order_item"]) + return false unless object_validator.valid?(@object) + related_object_validator = EnumAttributeValidator.new('String', ["product", "sku"]) + return false unless related_object_validator.valid?(@related_object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["order_item"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object Object to be assigned + def related_object=(related_object) + validator = EnumAttributeValidator.new('String', ["product", "sku"]) + unless validator.valid?(related_object) + fail ArgumentError, "invalid value for \"related_object\", must be one of #{validator.allowable_values}." + end + @related_object = related_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + source_id == o.source_id && + related_object == o.related_object && + product_id == o.product_id && + sku_id == o.sku_id && + quantity == o.quantity && + discount_quantity == o.discount_quantity && + amount == o.amount && + discount_amount == o.discount_amount && + applied_discount_amount == o.applied_discount_amount && + price == o.price + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, source_id, related_object, product_id, sku_id, quantity, discount_quantity, amount, discount_amount, applied_discount_amount, price].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_product.rb b/lib/VoucherifySdk/models/simple_product.rb new file mode 100644 index 00000000..2be3a105 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_product.rb @@ -0,0 +1,235 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleProduct + # Unique product ID. + attr_accessor :id + + # Product source id. + attr_accessor :source_id + + # Product name. + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleProduct` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleProduct`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_product_discount_unit.rb b/lib/VoucherifySdk/models/simple_product_discount_unit.rb new file mode 100644 index 00000000..dfe2fb20 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_product_discount_unit.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleProductDiscountUnit + # Unique product ID, assigned by Voucherify. + attr_accessor :id + + # Product's source ID. + attr_accessor :source_id + + # Product name. + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleProductDiscountUnit` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleProductDiscountUnit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_promotion_tier.rb b/lib/VoucherifySdk/models/simple_promotion_tier.rb new file mode 100644 index 00000000..eb4939dd --- /dev/null +++ b/lib/VoucherifySdk/models/simple_promotion_tier.rb @@ -0,0 +1,245 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a simple promotion tier. Promotion tiers are always assigned to a campaign and cannot be used standalone. + class SimplePromotionTier + # Unique promotion tier ID. + attr_accessor :id + + # Name of the promotion tier. + attr_accessor :name + + # Text to be displayed to your customers on your website. + attr_accessor :banner + + attr_accessor :campaign + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'banner' => :'banner', + :'campaign' => :'campaign' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'banner' => :'String', + :'campaign' => :'SimplePromotionTierCampaign' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimplePromotionTier` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimplePromotionTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + banner == o.banner && + campaign == o.campaign + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, banner, campaign].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_promotion_tier_campaign.rb b/lib/VoucherifySdk/models/simple_promotion_tier_campaign.rb new file mode 100644 index 00000000..621f5554 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_promotion_tier_campaign.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains details about promotion tier's parent campaign. + class SimplePromotionTierCampaign + # Unique campaign ID. + attr_accessor :id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimplePromotionTierCampaign` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimplePromotionTierCampaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_redemption.rb b/lib/VoucherifySdk/models/simple_redemption.rb new file mode 100644 index 00000000..3536e5f1 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_redemption.rb @@ -0,0 +1,368 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a simple redemption. + class SimpleRedemption + # Unique redemption ID. + attr_accessor :id + + # Unique customer ID of the redeeming customer. + attr_accessor :customer_id + + # Hashed customer source ID. + attr_accessor :tracking_id + + # Timestamp representing the date and time when the redemption was created in ISO 8601 format. + attr_accessor :date + + # A positive integer in the smallest currency unit (e.g. 100 cents for $1.00) representing the total amount of the order. This is the sum of the order items' amounts. + attr_accessor :amount + + attr_accessor :order + + attr_accessor :reward + + attr_accessor :customer + + # Redemption result. + attr_accessor :result + + attr_accessor :voucher + + attr_accessor :promotion_tier + + # Unique redemption ID of the parent redemption. + attr_accessor :redemption + + # The type of object represented by the JSON. This object stores information about the `redemption`. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'customer_id' => :'customer_id', + :'tracking_id' => :'tracking_id', + :'date' => :'date', + :'amount' => :'amount', + :'order' => :'order', + :'reward' => :'reward', + :'customer' => :'customer', + :'result' => :'result', + :'voucher' => :'voucher', + :'promotion_tier' => :'promotion_tier', + :'redemption' => :'redemption', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'customer_id' => :'String', + :'tracking_id' => :'String', + :'date' => :'Time', + :'amount' => :'Integer', + :'order' => :'SimpleOrder', + :'reward' => :'SimpleRedemptionRewardResult', + :'customer' => :'SimpleCustomer', + :'result' => :'String', + :'voucher' => :'SimpleVoucher', + :'promotion_tier' => :'SimplePromotionTier', + :'redemption' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'customer_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'date') + self.date = attributes[:'date'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'promotion_tier') + self.promotion_tier = attributes[:'promotion_tier'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'redemption' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + result_validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + return false unless result_validator.valid?(@result) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] result Object to be assigned + def result=(result) + validator = EnumAttributeValidator.new('String', ["SUCCESS", "FAILURE"]) + unless validator.valid?(result) + fail ArgumentError, "invalid value for \"result\", must be one of #{validator.allowable_values}." + end + @result = result + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + customer_id == o.customer_id && + tracking_id == o.tracking_id && + date == o.date && + amount == o.amount && + order == o.order && + reward == o.reward && + customer == o.customer && + result == o.result && + voucher == o.voucher && + promotion_tier == o.promotion_tier && + redemption == o.redemption && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, customer_id, tracking_id, date, amount, order, reward, customer, result, voucher, promotion_tier, redemption, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_redemption_reward_result.rb b/lib/VoucherifySdk/models/simple_redemption_reward_result.rb new file mode 100644 index 00000000..1286ac82 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_redemption_reward_result.rb @@ -0,0 +1,380 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleRedemptionRewardResult + attr_accessor :customer + + # Unique reward assignment ID assigned by Voucherify. + attr_accessor :assignment_id + + attr_accessor :voucher + + attr_accessor :product + + attr_accessor :sku + + # Unique loyalty tier ID assigned by Voucherify. + attr_accessor :loyalty_tier_id + + # Unique reward ID, assigned by Voucherify. + attr_accessor :id + + # The type of object represented by the JSON. This object stores information about the reward. + attr_accessor :object + + # Reward name. + attr_accessor :name + + # Timestamp representing the date and time when the reward was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the reward was updated in ISO 8601 format. + attr_accessor :updated_at + + # Defines how the reward is generated. + attr_accessor :parameters + + # Reward type. + attr_accessor :type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer', + :'assignment_id' => :'assignment_id', + :'voucher' => :'voucher', + :'product' => :'product', + :'sku' => :'sku', + :'loyalty_tier_id' => :'loyalty_tier_id', + :'id' => :'id', + :'object' => :'object', + :'name' => :'name', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'parameters' => :'parameters', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'SimpleCustomer', + :'assignment_id' => :'String', + :'voucher' => :'SimpleVoucher', + :'product' => :'SimpleProduct', + :'sku' => :'SimpleSku', + :'loyalty_tier_id' => :'String', + :'id' => :'String', + :'object' => :'String', + :'name' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'parameters' => :'Object', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'updated_at', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleRedemptionRewardResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleRedemptionRewardResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'assignment_id') + self.assignment_id = attributes[:'assignment_id'] + end + + if attributes.key?(:'voucher') + self.voucher = attributes[:'voucher'] + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + + if attributes.key?(:'loyalty_tier_id') + self.loyalty_tier_id = attributes[:'loyalty_tier_id'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'reward' + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + object_validator = EnumAttributeValidator.new('String', ["reward"]) + return false unless object_validator.valid?(@object) + type_validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["reward"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["CAMPAIGN", "COIN", "MATERIAL"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer && + assignment_id == o.assignment_id && + voucher == o.voucher && + product == o.product && + sku == o.sku && + loyalty_tier_id == o.loyalty_tier_id && + id == o.id && + object == o.object && + name == o.name && + created_at == o.created_at && + updated_at == o.updated_at && + parameters == o.parameters && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer, assignment_id, voucher, product, sku, loyalty_tier_id, id, object, name, created_at, updated_at, parameters, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_referral_tier.rb b/lib/VoucherifySdk/models/simple_referral_tier.rb new file mode 100644 index 00000000..e98ce132 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_referral_tier.rb @@ -0,0 +1,245 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleReferralTier + # Unique referral tier ID. + attr_accessor :id + + # Campaign Id. + attr_accessor :campaign_id + + # Text to be displayed to your customers on your website. + attr_accessor :banner + + # Referral tier parameters + attr_accessor :parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'campaign_id' => :'campaign_id', + :'banner' => :'banner', + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'campaign_id' => :'String', + :'banner' => :'String', + :'parameters' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleReferralTier` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleReferralTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + campaign_id == o.campaign_id && + banner == o.banner && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, campaign_id, banner, parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_segment.rb b/lib/VoucherifySdk/models/simple_segment.rb new file mode 100644 index 00000000..2c5b2687 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_segment.rb @@ -0,0 +1,290 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleSegment + # Unique segment ID. + attr_accessor :id + + # Segment name. + attr_accessor :name + + # The type of object represented by the ID. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleSegment` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleSegment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'segment' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["segment"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["segment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_sku.rb b/lib/VoucherifySdk/models/simple_sku.rb new file mode 100644 index 00000000..a3df4ed2 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_sku.rb @@ -0,0 +1,235 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleSku + # Unique sku ID. + attr_accessor :id + + # Sku source id. + attr_accessor :source_id + + # Sku name. + attr_accessor :sku + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'sku' => :'sku' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'sku' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleSku` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleSku`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + sku == o.sku + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, sku].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_sku_discount_unit.rb b/lib/VoucherifySdk/models/simple_sku_discount_unit.rb new file mode 100644 index 00000000..997eca37 --- /dev/null +++ b/lib/VoucherifySdk/models/simple_sku_discount_unit.rb @@ -0,0 +1,249 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleSkuDiscountUnit + # Unique SKU ID, assigned by Voucherify. + attr_accessor :id + + # Product variant's source ID. + attr_accessor :source_id + + # Sku name + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleSkuDiscountUnit` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleSkuDiscountUnit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/simple_voucher.rb b/lib/VoucherifySdk/models/simple_voucher.rb new file mode 100644 index 00000000..3384bc6e --- /dev/null +++ b/lib/VoucherifySdk/models/simple_voucher.rb @@ -0,0 +1,390 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SimpleVoucher + # A unique identifier that represents the voucher assigned by Voucherify. + attr_accessor :id + + # Voucher code. + attr_accessor :code + + attr_accessor :gift + + attr_accessor :discount + + # Defines the loyalty card details. + attr_accessor :loyalty_card + + # Type of the object. + attr_accessor :type + + # Campaign object + attr_accessor :campaign + + # Campaign unique ID. + attr_accessor :campaign_id + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Unique customer ID of campaign owner. + attr_accessor :holder_id + + # Unique referrer ID. + attr_accessor :referrer_id + + # Timestamp representing the date and time when the order was created in ISO 8601 format. + attr_accessor :created_at + + # The type of object represented by JSON. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'gift' => :'gift', + :'discount' => :'discount', + :'loyalty_card' => :'loyalty_card', + :'type' => :'type', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'is_referral_code' => :'is_referral_code', + :'holder_id' => :'holder_id', + :'referrer_id' => :'referrer_id', + :'created_at' => :'created_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'gift' => :'Gift', + :'discount' => :'Discount', + :'loyalty_card' => :'Object', + :'type' => :'String', + :'campaign' => :'Object', + :'campaign_id' => :'String', + :'is_referral_code' => :'Boolean', + :'holder_id' => :'String', + :'referrer_id' => :'String', + :'created_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleVoucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'voucher' + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'referrer_id') + self.referrer_id = attributes[:'referrer_id'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @code.nil? + type_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless type_validator.valid?(@type) + object_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + gift == o.gift && + discount == o.discount && + loyalty_card == o.loyalty_card && + type == o.type && + campaign == o.campaign && + campaign_id == o.campaign_id && + is_referral_code == o.is_referral_code && + holder_id == o.holder_id && + referrer_id == o.referrer_id && + created_at == o.created_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, gift, discount, loyalty_card, type, campaign, campaign_id, is_referral_code, holder_id, referrer_id, created_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/sku.rb b/lib/VoucherifySdk/models/sku.rb new file mode 100644 index 00000000..188790f1 --- /dev/null +++ b/lib/VoucherifySdk/models/sku.rb @@ -0,0 +1,418 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a product SKU. + class Sku + # A unique identifier that represents the SKU and is assigned by Voucherify. + attr_accessor :id + + # A unique SKU identifier from your inventory system. + attr_accessor :source_id + + # The parent product's unique ID. + attr_accessor :product_id + + # Unique user-defined SKU name. + attr_accessor :sku + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the SKU was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the SKU was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the `SKU`. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'sku', + :'price', + :'currency', + :'image_url', + :'updated_at', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Sku` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Sku`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + else + self.product_id = nil + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + else + self.sku = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + else + self.attributes = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + else + self.image_url = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'sku' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @product_id.nil? + invalid_properties.push('invalid value for "product_id", product_id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @product_id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, product_id, sku, price, currency, attributes, image_url, metadata, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/sku_with_product.rb b/lib/VoucherifySdk/models/sku_with_product.rb new file mode 100644 index 00000000..13851082 --- /dev/null +++ b/lib/VoucherifySdk/models/sku_with_product.rb @@ -0,0 +1,433 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class SkuWithProduct + # A unique identifier that represents the SKU and is assigned by Voucherify. + attr_accessor :id + + # A unique SKU identifier from your inventory system. + attr_accessor :source_id + + # The parent product's unique ID. + attr_accessor :product_id + + # Unique user-defined SKU name. + attr_accessor :sku + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the SKU was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the SKU was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the `SKU`. + attr_accessor :object + + attr_accessor :product + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object', + :'product' => :'product' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String', + :'product' => :'ProductWithoutSkus' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'sku', + :'price', + :'currency', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Sku' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SkuWithProduct` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SkuWithProduct`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + else + self.product_id = nil + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + else + self.sku = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + else + self.attributes = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + else + self.image_url = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'sku' + end + + if attributes.key?(:'product') + self.product = attributes[:'product'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @product_id.nil? + invalid_properties.push('invalid value for "product_id", product_id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @product_id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object && + product == o.product + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, product_id, sku, price, currency, attributes, image_url, metadata, created_at, updated_at, object, product].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/skus_get_response_body.rb b/lib/VoucherifySdk/models/skus_get_response_body.rb new file mode 100644 index 00000000..50f4070e --- /dev/null +++ b/lib/VoucherifySdk/models/skus_get_response_body.rb @@ -0,0 +1,425 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/skus/{skuId}`. + class SkusGetResponseBody + # A unique identifier that represents the SKU and is assigned by Voucherify. + attr_accessor :id + + # A unique SKU identifier from your inventory system. + attr_accessor :source_id + + # The parent product's unique ID. + attr_accessor :product_id + + # Unique user-defined SKU name. + attr_accessor :sku + + # Unit price. It is represented by a value multiplied by 100 to accurately reflect 2 decimal places, such as `$100.00` being expressed as `10000`. + attr_accessor :price + + # SKU price currency. + attr_accessor :currency + + # The attributes object stores values for all custom attributes inherited by the SKU from the parent product. A set of key/value pairs that are attached to a SKU object and are unique to each SKU within a product family. + attr_accessor :attributes + + # The HTTPS URL pointing to the .png or .jpg file that will be used to render the SKU image. + attr_accessor :image_url + + # The metadata object stores all custom attributes assigned to the SKU. A set of key/value pairs that you can attach to a SKU object. It can be useful for storing additional information about the SKU in a structured format. + attr_accessor :metadata + + # Timestamp representing the date and time when the SKU was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the SKU was updated in ISO 8601 format. + attr_accessor :updated_at + + # The type of object represented by JSON. This object stores information about the `SKU`. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'product_id' => :'product_id', + :'sku' => :'sku', + :'price' => :'price', + :'currency' => :'currency', + :'attributes' => :'attributes', + :'image_url' => :'image_url', + :'metadata' => :'metadata', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'product_id' => :'String', + :'sku' => :'String', + :'price' => :'Integer', + :'currency' => :'String', + :'attributes' => :'Object', + :'image_url' => :'String', + :'metadata' => :'Object', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'sku', + :'price', + :'currency', + :'image_url', + :'updated_at', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Sku' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SkusGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SkusGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'product_id') + self.product_id = attributes[:'product_id'] + else + self.product_id = nil + end + + if attributes.key?(:'sku') + self.sku = attributes[:'sku'] + else + self.sku = nil + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + else + self.price = nil + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + else + self.attributes = nil + end + + if attributes.key?(:'image_url') + self.image_url = attributes[:'image_url'] + else + self.image_url = nil + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + else + self.metadata = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + else + self.updated_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'sku' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @product_id.nil? + invalid_properties.push('invalid value for "product_id", product_id cannot be nil.') + end + + if @attributes.nil? + invalid_properties.push('invalid value for "attributes", attributes cannot be nil.') + end + + if @metadata.nil? + invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @product_id.nil? + return false if @attributes.nil? + return false if @metadata.nil? + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["sku"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["sku"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + product_id == o.product_id && + sku == o.sku && + price == o.price && + currency == o.currency && + attributes == o.attributes && + image_url == o.image_url && + metadata == o.metadata && + created_at == o.created_at && + updated_at == o.updated_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, product_id, sku, price, currency, attributes, image_url, metadata, created_at, updated_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/skus_import_csv_create_response_body.rb b/lib/VoucherifySdk/models/skus_import_csv_create_response_body.rb new file mode 100644 index 00000000..064e6701 --- /dev/null +++ b/lib/VoucherifySdk/models/skus_import_csv_create_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/skus/importCSV`. + class SkusImportCsvCreateResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SkusImportCsvCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SkusImportCsvCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/skus_list.rb b/lib/VoucherifySdk/models/skus_list.rb new file mode 100644 index 00000000..2a167e60 --- /dev/null +++ b/lib/VoucherifySdk/models/skus_list.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about SKUs. + class SkusList + # The type of object represented by JSON. This object stores information about SKUs. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of SKUs. + attr_accessor :data_ref + + # A dictionary that contains an array of SKUs. + attr_accessor :skus + + # Total number of SKUs in the product. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'skus' => :'skus', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'skus' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SkusList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SkusList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'skus') + if (value = attributes[:'skus']).is_a?(Array) + self.skus = value + end + else + self.skus = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @skus.nil? + invalid_properties.push('invalid value for "skus", skus cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @skus.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + skus == o.skus && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, skus, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/skus_list_for_product.rb b/lib/VoucherifySdk/models/skus_list_for_product.rb new file mode 100644 index 00000000..c6af2bb2 --- /dev/null +++ b/lib/VoucherifySdk/models/skus_list_for_product.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about child SKUs. + class SkusListForProduct + # The type of object represented by JSON. This object stores information about SKUs. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of SKUs. + attr_accessor :data_ref + + # A dictionary that contains an array of SKUs. + attr_accessor :data + + # Total number of SKUs in the product. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SkusListForProduct` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SkusListForProduct`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/stackable_validate_redeem_base.rb b/lib/VoucherifySdk/models/stackable_validate_redeem_base.rb new file mode 100644 index 00000000..910f49a9 --- /dev/null +++ b/lib/VoucherifySdk/models/stackable_validate_redeem_base.rb @@ -0,0 +1,299 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class StackableValidateRedeemBase + # An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. + attr_accessor :redeemables + + attr_accessor :order + + attr_accessor :customer + + attr_accessor :session + + # Is correspondent to Customer's source_id + attr_accessor :tracking_id + + # A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. + attr_accessor :metadata + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables' => :'redeemables', + :'order' => :'order', + :'customer' => :'customer', + :'session' => :'session', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables' => :'Array', + :'order' => :'Order', + :'customer' => :'Customer', + :'session' => :'Session', + :'tracking_id' => :'String', + :'metadata' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::StackableValidateRedeemBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::StackableValidateRedeemBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + else + self.redeemables = nil + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'session') + self.session = attributes[:'session'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemables.nil? + invalid_properties.push('invalid value for "redeemables", redeemables cannot be nil.') + end + + if @redeemables.length > 5 + invalid_properties.push('invalid value for "redeemables", number of items must be less than or equal to 5.') + end + + if @redeemables.length < 1 + invalid_properties.push('invalid value for "redeemables", number of items must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemables.nil? + return false if @redeemables.length > 5 + return false if @redeemables.length < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] redeemables Value to be assigned + def redeemables=(redeemables) + if redeemables.nil? + fail ArgumentError, 'redeemables cannot be nil' + end + + if redeemables.length > 5 + fail ArgumentError, 'invalid value for "redeemables", number of items must be less than or equal to 5.' + end + + if redeemables.length < 1 + fail ArgumentError, 'invalid value for "redeemables", number of items must be greater than or equal to 1.' + end + + @redeemables = redeemables + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables == o.redeemables && + order == o.order && + customer == o.customer && + session == o.session && + tracking_id == o.tracking_id && + metadata == o.metadata + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables, order, customer, session, tracking_id, metadata].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/stackable_validate_redeem_base_redeemables_item.rb b/lib/VoucherifySdk/models/stackable_validate_redeem_base_redeemables_item.rb new file mode 100644 index 00000000..e40c5cfb --- /dev/null +++ b/lib/VoucherifySdk/models/stackable_validate_redeem_base_redeemables_item.rb @@ -0,0 +1,108 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module StackableValidateRedeemBaseRedeemablesItem + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'RedeemGiftCard', + :'RedeemLoyaltyCard', + :'RedeemPromotionStack', + :'RedeemPromotionTier', + :'RedeemVoucher' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/stacking_rules.rb b/lib/VoucherifySdk/models/stacking_rules.rb new file mode 100644 index 00000000..ccdedc28 --- /dev/null +++ b/lib/VoucherifySdk/models/stacking_rules.rb @@ -0,0 +1,487 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines stacking rules for redeemables. Read more in the [Help Center](https://support.voucherify.io/article/604-stacking-rules) + class StackingRules + # Defines how many redeemables can be sent in one stacking request (note: more redeemables means more processing time!). + attr_accessor :redeemables_limit + + # Defines how many of the sent redeemables will be applied to the order. For example, a user can select 30 discounts but only 5 will be applied to the order and the remaining will be labelled as SKIPPED. + attr_accessor :applicable_redeemables_limit + + # Defines how many redeemables with an exclusive category can be applied in one request. + attr_accessor :applicable_exclusive_redeemables_limit + + # Defines how many redeemables per category can be applied in one request. + attr_accessor :applicable_redeemables_per_category_limit + + # Lists all exclusive categories. A redeemable from a campaign with an exclusive category is the only redeemable to be redeemed when applied with redeemables from other campaigns unless these campaigns are exclusive or joint. + attr_accessor :exclusive_categories + + # Lists all joint categories. A campaign with a joint category is always applied regardless of the exclusivity of other campaigns. + attr_accessor :joint_categories + + # Defines redeemables application mode. + attr_accessor :redeemables_application_mode + + # Defines redeemables sorting rule. + attr_accessor :redeemables_sorting_rule + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables_limit' => :'redeemables_limit', + :'applicable_redeemables_limit' => :'applicable_redeemables_limit', + :'applicable_exclusive_redeemables_limit' => :'applicable_exclusive_redeemables_limit', + :'applicable_redeemables_per_category_limit' => :'applicable_redeemables_per_category_limit', + :'exclusive_categories' => :'exclusive_categories', + :'joint_categories' => :'joint_categories', + :'redeemables_application_mode' => :'redeemables_application_mode', + :'redeemables_sorting_rule' => :'redeemables_sorting_rule' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables_limit' => :'Integer', + :'applicable_redeemables_limit' => :'Integer', + :'applicable_exclusive_redeemables_limit' => :'Integer', + :'applicable_redeemables_per_category_limit' => :'Integer', + :'exclusive_categories' => :'Array', + :'joint_categories' => :'Array', + :'redeemables_application_mode' => :'String', + :'redeemables_sorting_rule' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::StackingRules` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::StackingRules`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables_limit') + self.redeemables_limit = attributes[:'redeemables_limit'] + else + self.redeemables_limit = 30 + end + + if attributes.key?(:'applicable_redeemables_limit') + self.applicable_redeemables_limit = attributes[:'applicable_redeemables_limit'] + else + self.applicable_redeemables_limit = 5 + end + + if attributes.key?(:'applicable_exclusive_redeemables_limit') + self.applicable_exclusive_redeemables_limit = attributes[:'applicable_exclusive_redeemables_limit'] + else + self.applicable_exclusive_redeemables_limit = 1 + end + + if attributes.key?(:'applicable_redeemables_per_category_limit') + self.applicable_redeemables_per_category_limit = attributes[:'applicable_redeemables_per_category_limit'] + else + self.applicable_redeemables_per_category_limit = 1 + end + + if attributes.key?(:'exclusive_categories') + if (value = attributes[:'exclusive_categories']).is_a?(Array) + self.exclusive_categories = value + end + else + self.exclusive_categories = nil + end + + if attributes.key?(:'joint_categories') + if (value = attributes[:'joint_categories']).is_a?(Array) + self.joint_categories = value + end + else + self.joint_categories = nil + end + + if attributes.key?(:'redeemables_application_mode') + self.redeemables_application_mode = attributes[:'redeemables_application_mode'] + end + + if attributes.key?(:'redeemables_sorting_rule') + self.redeemables_sorting_rule = attributes[:'redeemables_sorting_rule'] + else + self.redeemables_sorting_rule = 'REQUESTED_ORDER' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemables_limit.nil? + invalid_properties.push('invalid value for "redeemables_limit", redeemables_limit cannot be nil.') + end + + if @redeemables_limit > 30 + invalid_properties.push('invalid value for "redeemables_limit", must be smaller than or equal to 30.') + end + + if @redeemables_limit < 1 + invalid_properties.push('invalid value for "redeemables_limit", must be greater than or equal to 1.') + end + + if @applicable_redeemables_limit.nil? + invalid_properties.push('invalid value for "applicable_redeemables_limit", applicable_redeemables_limit cannot be nil.') + end + + if @applicable_redeemables_limit > 30 + invalid_properties.push('invalid value for "applicable_redeemables_limit", must be smaller than or equal to 30.') + end + + if @applicable_redeemables_limit < 1 + invalid_properties.push('invalid value for "applicable_redeemables_limit", must be greater than or equal to 1.') + end + + if @applicable_exclusive_redeemables_limit.nil? + invalid_properties.push('invalid value for "applicable_exclusive_redeemables_limit", applicable_exclusive_redeemables_limit cannot be nil.') + end + + if @applicable_exclusive_redeemables_limit > 30 + invalid_properties.push('invalid value for "applicable_exclusive_redeemables_limit", must be smaller than or equal to 30.') + end + + if @applicable_exclusive_redeemables_limit < 1 + invalid_properties.push('invalid value for "applicable_exclusive_redeemables_limit", must be greater than or equal to 1.') + end + + if !@applicable_redeemables_per_category_limit.nil? && @applicable_redeemables_per_category_limit > 30 + invalid_properties.push('invalid value for "applicable_redeemables_per_category_limit", must be smaller than or equal to 30.') + end + + if !@applicable_redeemables_per_category_limit.nil? && @applicable_redeemables_per_category_limit < 1 + invalid_properties.push('invalid value for "applicable_redeemables_per_category_limit", must be greater than or equal to 1.') + end + + if @exclusive_categories.nil? + invalid_properties.push('invalid value for "exclusive_categories", exclusive_categories cannot be nil.') + end + + if @joint_categories.nil? + invalid_properties.push('invalid value for "joint_categories", joint_categories cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemables_limit.nil? + return false if @redeemables_limit > 30 + return false if @redeemables_limit < 1 + return false if @applicable_redeemables_limit.nil? + return false if @applicable_redeemables_limit > 30 + return false if @applicable_redeemables_limit < 1 + return false if @applicable_exclusive_redeemables_limit.nil? + return false if @applicable_exclusive_redeemables_limit > 30 + return false if @applicable_exclusive_redeemables_limit < 1 + return false if !@applicable_redeemables_per_category_limit.nil? && @applicable_redeemables_per_category_limit > 30 + return false if !@applicable_redeemables_per_category_limit.nil? && @applicable_redeemables_per_category_limit < 1 + return false if @exclusive_categories.nil? + return false if @joint_categories.nil? + redeemables_application_mode_validator = EnumAttributeValidator.new('String', ["ALL", "PARTIAL"]) + return false unless redeemables_application_mode_validator.valid?(@redeemables_application_mode) + redeemables_sorting_rule_validator = EnumAttributeValidator.new('String', ["CATEGORY_HIERARCHY", "REQUESTED_ORDER"]) + return false unless redeemables_sorting_rule_validator.valid?(@redeemables_sorting_rule) + true + end + + # Custom attribute writer method with validation + # @param [Object] redeemables_limit Value to be assigned + def redeemables_limit=(redeemables_limit) + if redeemables_limit.nil? + fail ArgumentError, 'redeemables_limit cannot be nil' + end + + if redeemables_limit > 30 + fail ArgumentError, 'invalid value for "redeemables_limit", must be smaller than or equal to 30.' + end + + if redeemables_limit < 1 + fail ArgumentError, 'invalid value for "redeemables_limit", must be greater than or equal to 1.' + end + + @redeemables_limit = redeemables_limit + end + + # Custom attribute writer method with validation + # @param [Object] applicable_redeemables_limit Value to be assigned + def applicable_redeemables_limit=(applicable_redeemables_limit) + if applicable_redeemables_limit.nil? + fail ArgumentError, 'applicable_redeemables_limit cannot be nil' + end + + if applicable_redeemables_limit > 30 + fail ArgumentError, 'invalid value for "applicable_redeemables_limit", must be smaller than or equal to 30.' + end + + if applicable_redeemables_limit < 1 + fail ArgumentError, 'invalid value for "applicable_redeemables_limit", must be greater than or equal to 1.' + end + + @applicable_redeemables_limit = applicable_redeemables_limit + end + + # Custom attribute writer method with validation + # @param [Object] applicable_exclusive_redeemables_limit Value to be assigned + def applicable_exclusive_redeemables_limit=(applicable_exclusive_redeemables_limit) + if applicable_exclusive_redeemables_limit.nil? + fail ArgumentError, 'applicable_exclusive_redeemables_limit cannot be nil' + end + + if applicable_exclusive_redeemables_limit > 30 + fail ArgumentError, 'invalid value for "applicable_exclusive_redeemables_limit", must be smaller than or equal to 30.' + end + + if applicable_exclusive_redeemables_limit < 1 + fail ArgumentError, 'invalid value for "applicable_exclusive_redeemables_limit", must be greater than or equal to 1.' + end + + @applicable_exclusive_redeemables_limit = applicable_exclusive_redeemables_limit + end + + # Custom attribute writer method with validation + # @param [Object] applicable_redeemables_per_category_limit Value to be assigned + def applicable_redeemables_per_category_limit=(applicable_redeemables_per_category_limit) + if applicable_redeemables_per_category_limit.nil? + fail ArgumentError, 'applicable_redeemables_per_category_limit cannot be nil' + end + + if applicable_redeemables_per_category_limit > 30 + fail ArgumentError, 'invalid value for "applicable_redeemables_per_category_limit", must be smaller than or equal to 30.' + end + + if applicable_redeemables_per_category_limit < 1 + fail ArgumentError, 'invalid value for "applicable_redeemables_per_category_limit", must be greater than or equal to 1.' + end + + @applicable_redeemables_per_category_limit = applicable_redeemables_per_category_limit + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] redeemables_application_mode Object to be assigned + def redeemables_application_mode=(redeemables_application_mode) + validator = EnumAttributeValidator.new('String', ["ALL", "PARTIAL"]) + unless validator.valid?(redeemables_application_mode) + fail ArgumentError, "invalid value for \"redeemables_application_mode\", must be one of #{validator.allowable_values}." + end + @redeemables_application_mode = redeemables_application_mode + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] redeemables_sorting_rule Object to be assigned + def redeemables_sorting_rule=(redeemables_sorting_rule) + validator = EnumAttributeValidator.new('String', ["CATEGORY_HIERARCHY", "REQUESTED_ORDER"]) + unless validator.valid?(redeemables_sorting_rule) + fail ArgumentError, "invalid value for \"redeemables_sorting_rule\", must be one of #{validator.allowable_values}." + end + @redeemables_sorting_rule = redeemables_sorting_rule + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables_limit == o.redeemables_limit && + applicable_redeemables_limit == o.applicable_redeemables_limit && + applicable_exclusive_redeemables_limit == o.applicable_exclusive_redeemables_limit && + applicable_redeemables_per_category_limit == o.applicable_redeemables_per_category_limit && + exclusive_categories == o.exclusive_categories && + joint_categories == o.joint_categories && + redeemables_application_mode == o.redeemables_application_mode && + redeemables_sorting_rule == o.redeemables_sorting_rule + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables_limit, applicable_redeemables_limit, applicable_exclusive_redeemables_limit, applicable_redeemables_per_category_limit, exclusive_categories, joint_categories, redeemables_application_mode, redeemables_sorting_rule].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_entity.rb b/lib/VoucherifySdk/models/validation_entity.rb new file mode 100644 index 00000000..02595161 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_entity.rb @@ -0,0 +1,325 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ValidationEntity + # Unique validation id. + attr_accessor :id + + # Unique session id. + attr_accessor :session_id + + # The validation status + attr_accessor :status + + # Timestamp representing the date and time when the validation was created in ISO 8601 format. + attr_accessor :created_at + + # Unique customer ID of the customer making the purchase. + attr_accessor :customer_id + + # Lists validation results of each redeemable. + attr_accessor :redeemables + + # Lists validation results of each redeemable. + attr_accessor :skipped_redeemables + + # Lists validation results of each redeemable. + attr_accessor :inapplicable_redeemables + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'session_id' => :'session_id', + :'status' => :'status', + :'created_at' => :'created_at', + :'customer_id' => :'customer_id', + :'redeemables' => :'redeemables', + :'skipped_redeemables' => :'skipped_redeemables', + :'inapplicable_redeemables' => :'inapplicable_redeemables' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'session_id' => :'String', + :'status' => :'String', + :'created_at' => :'Time', + :'customer_id' => :'String', + :'redeemables' => :'Array', + :'skipped_redeemables' => :'Array', + :'inapplicable_redeemables' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationEntity` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationEntity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'session_id') + self.session_id = attributes[:'session_id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'customer_id') + self.customer_id = attributes[:'customer_id'] + end + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + end + + if attributes.key?(:'skipped_redeemables') + if (value = attributes[:'skipped_redeemables']).is_a?(Array) + self.skipped_redeemables = value + end + end + + if attributes.key?(:'inapplicable_redeemables') + if (value = attributes[:'inapplicable_redeemables']).is_a?(Array) + self.inapplicable_redeemables = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["VALID", "INVALID"]) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["VALID", "INVALID"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + session_id == o.session_id && + status == o.status && + created_at == o.created_at && + customer_id == o.customer_id && + redeemables == o.redeemables && + skipped_redeemables == o.skipped_redeemables && + inapplicable_redeemables == o.inapplicable_redeemables + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, session_id, status, created_at, customer_id, redeemables, skipped_redeemables, inapplicable_redeemables].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rule.rb b/lib/VoucherifySdk/models/validation_rule.rb new file mode 100644 index 00000000..72750171 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rule.rb @@ -0,0 +1,422 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ValidationRule + # Custom, unique name for set of validation rules. + attr_accessor :name + + # Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. + attr_accessor :rules + + attr_accessor :error + + attr_accessor :applicable_to + + # Type of validation rule. + attr_accessor :type + + # Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | + attr_accessor :context_type + + # Unique validation rule ID. + attr_accessor :id + + # Timestamp representing the date and time when the validation rule was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. + attr_accessor :updated_at + + # The number of instances the validation rule has been assigned to different types of redeemables. + attr_accessor :assignments_count + + # The type of object represented by JSON. This object stores information about the validation rule. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'rules' => :'rules', + :'error' => :'error', + :'applicable_to' => :'applicable_to', + :'type' => :'type', + :'context_type' => :'context_type', + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assignments_count' => :'assignments_count', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'rules' => :'Object', + :'error' => :'ValidationRuleBaseError', + :'applicable_to' => :'ValidationRuleBaseApplicableTo', + :'type' => :'String', + :'context_type' => :'String', + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assignments_count' => :'Integer', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationRuleBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRule` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRule`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'rules') + self.rules = attributes[:'rules'] + else + self.rules = nil + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + else + self.applicable_to = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'expression' + end + + if attributes.key?(:'context_type') + self.context_type = attributes[:'context_type'] + else + self.context_type = 'global' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assignments_count') + self.assignments_count = attributes[:'assignments_count'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'validation_rules' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @rules.nil? + invalid_properties.push('invalid value for "rules", rules cannot be nil.') + end + + if @applicable_to.nil? + invalid_properties.push('invalid value for "applicable_to", applicable_to cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @context_type.nil? + invalid_properties.push('invalid value for "context_type", context_type cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @rules.nil? + return false if @applicable_to.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + return false unless type_validator.valid?(@type) + return false if @context_type.nil? + context_type_validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + return false unless context_type_validator.valid?(@context_type) + return false if @id.nil? + return false if @created_at.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] context_type Object to be assigned + def context_type=(context_type) + validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + unless validator.valid?(context_type) + fail ArgumentError, "invalid value for \"context_type\", must be one of #{validator.allowable_values}." + end + @context_type = context_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + rules == o.rules && + error == o.error && + applicable_to == o.applicable_to && + type == o.type && + context_type == o.context_type && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + assignments_count == o.assignments_count && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, rules, error, applicable_to, type, context_type, id, created_at, updated_at, assignments_count, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rule_assignment.rb b/lib/VoucherifySdk/models/validation_rule_assignment.rb new file mode 100644 index 00000000..8ba36b05 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rule_assignment.rb @@ -0,0 +1,354 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a validation rule assignment. + class ValidationRuleAssignment + # Validation rule assignment ID. + attr_accessor :id + + # Validation rule ID. + attr_accessor :rule_id + + # The resource ID to which the validation rule was assigned. + attr_accessor :related_object_id + + # The type of resource to which the validation rule was assigned. + attr_accessor :related_object_type + + # Timestamp representing the date and time when the validation rule assignment was created in ISO 8601 format. + attr_accessor :created_at + + # The type of object represented by the ID. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'rule_id' => :'rule_id', + :'related_object_id' => :'related_object_id', + :'related_object_type' => :'related_object_type', + :'created_at' => :'created_at', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'rule_id' => :'String', + :'related_object_id' => :'String', + :'related_object_type' => :'String', + :'created_at' => :'Time', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRuleAssignment` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRuleAssignment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'rule_id') + self.rule_id = attributes[:'rule_id'] + else + self.rule_id = nil + end + + if attributes.key?(:'related_object_id') + self.related_object_id = attributes[:'related_object_id'] + else + self.related_object_id = nil + end + + if attributes.key?(:'related_object_type') + self.related_object_type = attributes[:'related_object_type'] + else + self.related_object_type = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'validation_rules_assignment' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @rule_id.nil? + invalid_properties.push('invalid value for "rule_id", rule_id cannot be nil.') + end + + if @related_object_id.nil? + invalid_properties.push('invalid value for "related_object_id", related_object_id cannot be nil.') + end + + if @related_object_type.nil? + invalid_properties.push('invalid value for "related_object_type", related_object_type cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @rule_id.nil? + return false if @related_object_id.nil? + return false if @related_object_type.nil? + related_object_type_validator = EnumAttributeValidator.new('String', ["voucher", "campaign", "earning_rule", "reward_assignment", "promotion_tier", "distribution"]) + return false unless related_object_type_validator.valid?(@related_object_type) + return false if @created_at.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["validation_rules_assignment"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] related_object_type Object to be assigned + def related_object_type=(related_object_type) + validator = EnumAttributeValidator.new('String', ["voucher", "campaign", "earning_rule", "reward_assignment", "promotion_tier", "distribution"]) + unless validator.valid?(related_object_type) + fail ArgumentError, "invalid value for \"related_object_type\", must be one of #{validator.allowable_values}." + end + @related_object_type = related_object_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["validation_rules_assignment"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + rule_id == o.rule_id && + related_object_id == o.related_object_id && + related_object_type == o.related_object_type && + created_at == o.created_at && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, rule_id, related_object_id, related_object_type, created_at, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rule_assignments_list.rb b/lib/VoucherifySdk/models/validation_rule_assignments_list.rb new file mode 100644 index 00000000..583d8abb --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rule_assignments_list.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Validation Rule Assignments List + class ValidationRuleAssignmentsList + # The type of object represented by JSON. This object stores information about validation rule assignments. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of validation rule assignments. + attr_accessor :data_ref + + # A dictionary that contains an array of validation rule assignments. + attr_accessor :data + + # Total number of validation rule assignments. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRuleAssignmentsList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRuleAssignmentsList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rule_base.rb b/lib/VoucherifySdk/models/validation_rule_base.rb new file mode 100644 index 00000000..a2470817 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rule_base.rb @@ -0,0 +1,314 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a request validation rule. + class ValidationRuleBase + # Custom, unique name for set of validation rules. + attr_accessor :name + + # Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. + attr_accessor :rules + + attr_accessor :error + + attr_accessor :applicable_to + + # Type of validation rule. + attr_accessor :type + + # Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | + attr_accessor :context_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'rules' => :'rules', + :'error' => :'error', + :'applicable_to' => :'applicable_to', + :'type' => :'type', + :'context_type' => :'context_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'rules' => :'Object', + :'error' => :'ValidationRuleBaseError', + :'applicable_to' => :'ValidationRuleBaseApplicableTo', + :'type' => :'String', + :'context_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRuleBase` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRuleBase`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'rules') + self.rules = attributes[:'rules'] + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'expression' + end + + if attributes.key?(:'context_type') + self.context_type = attributes[:'context_type'] + else + self.context_type = 'global' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + return false unless type_validator.valid?(@type) + context_type_validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + return false unless context_type_validator.valid?(@context_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] context_type Object to be assigned + def context_type=(context_type) + validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + unless validator.valid?(context_type) + fail ArgumentError, "invalid value for \"context_type\", must be one of #{validator.allowable_values}." + end + @context_type = context_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + rules == o.rules && + error == o.error && + applicable_to == o.applicable_to && + type == o.type && + context_type == o.context_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, rules, error, applicable_to, type, context_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rule_base_applicable_to.rb b/lib/VoucherifySdk/models/validation_rule_base_applicable_to.rb new file mode 100644 index 00000000..49dffae7 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rule_base_applicable_to.rb @@ -0,0 +1,239 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ValidationRuleBaseApplicableTo + # Defines which items are excluded from a discount. + attr_accessor :excluded + + # Defines which items are included in a discount. + attr_accessor :included + + # Indicates whether all items are included in the discount. + attr_accessor :included_all + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'excluded' => :'excluded', + :'included' => :'included', + :'included_all' => :'included_all' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'excluded' => :'Array', + :'included' => :'Array', + :'included_all' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRuleBaseApplicableTo` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRuleBaseApplicableTo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'excluded') + if (value = attributes[:'excluded']).is_a?(Array) + self.excluded = value + end + end + + if attributes.key?(:'included') + if (value = attributes[:'included']).is_a?(Array) + self.included = value + end + end + + if attributes.key?(:'included_all') + self.included_all = attributes[:'included_all'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + excluded == o.excluded && + included == o.included && + included_all == o.included_all + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [excluded, included, included_all].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rule_base_error.rb b/lib/VoucherifySdk/models/validation_rule_base_error.rb new file mode 100644 index 00000000..d2a479ec --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rule_base_error.rb @@ -0,0 +1,216 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the error message returned from API when validation / redemption fails to meet requirements of defined rules. + class ValidationRuleBaseError + # The error message returned from API when validation / redemption fails to meet requirements of defined rules. + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'message' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRuleBaseError` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRuleBaseError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_assignments_list.rb b/lib/VoucherifySdk/models/validation_rules_assignments_list.rb new file mode 100644 index 00000000..68017e39 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_assignments_list.rb @@ -0,0 +1,341 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of Validation Rules Assignments + class ValidationRulesAssignmentsList + # The type of object represented by JSON. This object stores information about validation rules assignments. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of validation rules assignments. + attr_accessor :data_ref + + # Contains array of validation rules assignments. + attr_accessor :data + + # Total number of validation rules assignments. + attr_accessor :total + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesAssignmentsList` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesAssignmentsList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @total < 0 + invalid_properties.push('invalid value for "total", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["list"]) + return false unless object_validator.valid?(@object) + return false if @data_ref.nil? + data_ref_validator = EnumAttributeValidator.new('String', ["data"]) + return false unless data_ref_validator.valid?(@data_ref) + return false if @data.nil? + return false if @total.nil? + return false if @total < 0 + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["list"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] data_ref Object to be assigned + def data_ref=(data_ref) + validator = EnumAttributeValidator.new('String', ["data"]) + unless validator.valid?(data_ref) + fail ArgumentError, "invalid value for \"data_ref\", must be one of #{validator.allowable_values}." + end + @data_ref = data_ref + end + + # Custom attribute writer method with validation + # @param [Object] total Value to be assigned + def total=(total) + if total.nil? + fail ArgumentError, 'total cannot be nil' + end + + if total < 0 + fail ArgumentError, 'invalid value for "total", must be greater than or equal to 0.' + end + + @total = total + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_assignments_list_response_body.rb b/lib/VoucherifySdk/models/validation_rules_assignments_list_response_body.rb new file mode 100644 index 00000000..e8f19c64 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_assignments_list_response_body.rb @@ -0,0 +1,283 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body for **GET** `/validation-rules-assignments` and **GET** `/validation-rules/{validationRuleId}/assignments`. + class ValidationRulesAssignmentsListResponseBody + # The type of object represented by JSON. This object stores information about validation rule assignments. + attr_accessor :object + + # Identifies the name of the JSON property that contains the array of validation rule assignments. + attr_accessor :data_ref + + # A dictionary that contains an array of validation rule assignments. + attr_accessor :data + + # Total number of validation rule assignments. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationRuleAssignmentsList' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesAssignmentsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesAssignmentsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_create_request_body.rb b/lib/VoucherifySdk/models/validation_rules_create_request_body.rb new file mode 100644 index 00000000..54b6a3b8 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_create_request_body.rb @@ -0,0 +1,328 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/validation-rules`. + class ValidationRulesCreateRequestBody + # Custom, unique name for set of validation rules. + attr_accessor :name + + # Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. + attr_accessor :rules + + attr_accessor :error + + attr_accessor :applicable_to + + # Type of validation rule. + attr_accessor :type + + # Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | + attr_accessor :context_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'rules' => :'rules', + :'error' => :'error', + :'applicable_to' => :'applicable_to', + :'type' => :'type', + :'context_type' => :'context_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'rules' => :'Object', + :'error' => :'ValidationRuleBaseError', + :'applicable_to' => :'ValidationRuleBaseApplicableTo', + :'type' => :'String', + :'context_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationRuleBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'rules') + self.rules = attributes[:'rules'] + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'expression' + end + + if attributes.key?(:'context_type') + self.context_type = attributes[:'context_type'] + else + self.context_type = 'global' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + type_validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + return false unless type_validator.valid?(@type) + context_type_validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + return false unless context_type_validator.valid?(@context_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] context_type Object to be assigned + def context_type=(context_type) + validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + unless validator.valid?(context_type) + fail ArgumentError, "invalid value for \"context_type\", must be one of #{validator.allowable_values}." + end + @context_type = context_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + rules == o.rules && + error == o.error && + applicable_to == o.applicable_to && + type == o.type && + context_type == o.context_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, rules, error, applicable_to, type, context_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_create_response_body.rb b/lib/VoucherifySdk/models/validation_rules_create_response_body.rb new file mode 100644 index 00000000..23cae9fb --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_create_response_body.rb @@ -0,0 +1,423 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/validation-rules`. + class ValidationRulesCreateResponseBody + # Custom, unique name for set of validation rules. + attr_accessor :name + + # Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. + attr_accessor :rules + + attr_accessor :error + + attr_accessor :applicable_to + + # Type of validation rule. + attr_accessor :type + + # Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | + attr_accessor :context_type + + # Unique validation rule ID. + attr_accessor :id + + # Timestamp representing the date and time when the validation rule was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. + attr_accessor :updated_at + + # The number of instances the validation rule has been assigned to different types of redeemables. + attr_accessor :assignments_count + + # The type of object represented by JSON. This object stores information about the validation rule. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'rules' => :'rules', + :'error' => :'error', + :'applicable_to' => :'applicable_to', + :'type' => :'type', + :'context_type' => :'context_type', + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assignments_count' => :'assignments_count', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'rules' => :'Object', + :'error' => :'ValidationRuleBaseError', + :'applicable_to' => :'ValidationRuleBaseApplicableTo', + :'type' => :'String', + :'context_type' => :'String', + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assignments_count' => :'Integer', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationRule' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'rules') + self.rules = attributes[:'rules'] + else + self.rules = nil + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + else + self.applicable_to = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'expression' + end + + if attributes.key?(:'context_type') + self.context_type = attributes[:'context_type'] + else + self.context_type = 'global' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assignments_count') + self.assignments_count = attributes[:'assignments_count'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'validation_rules' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @rules.nil? + invalid_properties.push('invalid value for "rules", rules cannot be nil.') + end + + if @applicable_to.nil? + invalid_properties.push('invalid value for "applicable_to", applicable_to cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @context_type.nil? + invalid_properties.push('invalid value for "context_type", context_type cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @rules.nil? + return false if @applicable_to.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + return false unless type_validator.valid?(@type) + return false if @context_type.nil? + context_type_validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + return false unless context_type_validator.valid?(@context_type) + return false if @id.nil? + return false if @created_at.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] context_type Object to be assigned + def context_type=(context_type) + validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + unless validator.valid?(context_type) + fail ArgumentError, "invalid value for \"context_type\", must be one of #{validator.allowable_values}." + end + @context_type = context_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + rules == o.rules && + error == o.error && + applicable_to == o.applicable_to && + type == o.type && + context_type == o.context_type && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + assignments_count == o.assignments_count && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, rules, error, applicable_to, type, context_type, id, created_at, updated_at, assignments_count, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_get_response_body.rb b/lib/VoucherifySdk/models/validation_rules_get_response_body.rb new file mode 100644 index 00000000..d3bd7bb5 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_get_response_body.rb @@ -0,0 +1,423 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/validation-rules/{validationRuleId}`. + class ValidationRulesGetResponseBody + # Custom, unique name for set of validation rules. + attr_accessor :name + + # Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. + attr_accessor :rules + + attr_accessor :error + + attr_accessor :applicable_to + + # Type of validation rule. + attr_accessor :type + + # Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | + attr_accessor :context_type + + # Unique validation rule ID. + attr_accessor :id + + # Timestamp representing the date and time when the validation rule was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. + attr_accessor :updated_at + + # The number of instances the validation rule has been assigned to different types of redeemables. + attr_accessor :assignments_count + + # The type of object represented by JSON. This object stores information about the validation rule. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'rules' => :'rules', + :'error' => :'error', + :'applicable_to' => :'applicable_to', + :'type' => :'type', + :'context_type' => :'context_type', + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assignments_count' => :'assignments_count', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'rules' => :'Object', + :'error' => :'ValidationRuleBaseError', + :'applicable_to' => :'ValidationRuleBaseApplicableTo', + :'type' => :'String', + :'context_type' => :'String', + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assignments_count' => :'Integer', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationRule' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'rules') + self.rules = attributes[:'rules'] + else + self.rules = nil + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + else + self.applicable_to = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'expression' + end + + if attributes.key?(:'context_type') + self.context_type = attributes[:'context_type'] + else + self.context_type = 'global' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assignments_count') + self.assignments_count = attributes[:'assignments_count'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'validation_rules' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @rules.nil? + invalid_properties.push('invalid value for "rules", rules cannot be nil.') + end + + if @applicable_to.nil? + invalid_properties.push('invalid value for "applicable_to", applicable_to cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @context_type.nil? + invalid_properties.push('invalid value for "context_type", context_type cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @rules.nil? + return false if @applicable_to.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + return false unless type_validator.valid?(@type) + return false if @context_type.nil? + context_type_validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + return false unless context_type_validator.valid?(@context_type) + return false if @id.nil? + return false if @created_at.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] context_type Object to be assigned + def context_type=(context_type) + validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + unless validator.valid?(context_type) + fail ArgumentError, "invalid value for \"context_type\", must be one of #{validator.allowable_values}." + end + @context_type = context_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + rules == o.rules && + error == o.error && + applicable_to == o.applicable_to && + type == o.type && + context_type == o.context_type && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + assignments_count == o.assignments_count && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, rules, error, applicable_to, type, context_type, id, created_at, updated_at, assignments_count, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_list_response_body.rb b/lib/VoucherifySdk/models/validation_rules_list_response_body.rb new file mode 100644 index 00000000..b3eaec21 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_list_response_body.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/validation-rules`. + class ValidationRulesListResponseBody + # The type of object represented by JSON. This object stores information about validation rules. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of validation rules. + attr_accessor :data_ref + + # An array of validation rules. + attr_accessor :data + + # Total number of validation rules in the project. + attr_accessor :total + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'total' => :'total' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'total' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @total.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + total == o.total + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, total].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_update_request_body.rb b/lib/VoucherifySdk/models/validation_rules_update_request_body.rb new file mode 100644 index 00000000..4fc283e1 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_update_request_body.rb @@ -0,0 +1,321 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/validation-rules/{validationRuleId}`. + class ValidationRulesUpdateRequestBody + # Custom, unique name for set of validation rules. + attr_accessor :name + + # Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. + attr_accessor :rules + + attr_accessor :error + + attr_accessor :applicable_to + + # Type of validation rule. + attr_accessor :type + + # Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | + attr_accessor :context_type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'rules' => :'rules', + :'error' => :'error', + :'applicable_to' => :'applicable_to', + :'type' => :'type', + :'context_type' => :'context_type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'rules' => :'Object', + :'error' => :'ValidationRuleBaseError', + :'applicable_to' => :'ValidationRuleBaseApplicableTo', + :'type' => :'String', + :'context_type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationRuleBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'rules') + self.rules = attributes[:'rules'] + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'expression' + end + + if attributes.key?(:'context_type') + self.context_type = attributes[:'context_type'] + else + self.context_type = 'global' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + return false unless type_validator.valid?(@type) + context_type_validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + return false unless context_type_validator.valid?(@context_type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] context_type Object to be assigned + def context_type=(context_type) + validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + unless validator.valid?(context_type) + fail ArgumentError, "invalid value for \"context_type\", must be one of #{validator.allowable_values}." + end + @context_type = context_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + rules == o.rules && + error == o.error && + applicable_to == o.applicable_to && + type == o.type && + context_type == o.context_type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, rules, error, applicable_to, type, context_type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validation_rules_update_response_body.rb b/lib/VoucherifySdk/models/validation_rules_update_response_body.rb new file mode 100644 index 00000000..0becd285 --- /dev/null +++ b/lib/VoucherifySdk/models/validation_rules_update_response_body.rb @@ -0,0 +1,423 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **PUT** `/validation-rules/{validationRuleId}`. + class ValidationRulesUpdateResponseBody + # Custom, unique name for set of validation rules. + attr_accessor :name + + # Contains all the rule definitions for the validation rule. It is a set of key value pairs representing the rules and logic between the rules. The keys are numbered consecutively beginning from `1`. The values are objects containing the rule conditions. + attr_accessor :rules + + attr_accessor :error + + attr_accessor :applicable_to + + # Type of validation rule. + attr_accessor :type + + # Validation rule context type. | **Context Type** | **Definition** | |:---|:---| | earning_rule.order.paid | | | earning_rule.custom_event | | | earning_rule.customer.segment.entered | | | campaign.discount_coupons | | | campaign.discount_coupons.discount.apply_to_order | | | campaign.discount_coupons.discount.apply_to_items | | | campaign.discount_coupons.discount.apply_to_items_proportionally | | | campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity | | | campaign.discount_coupons.discount.fixed.apply_to_items | | | campaign.gift_vouchers | | | campaign.gift_vouchers.gift.apply_to_order | | | campaign.gift_vouchers.gift.apply_to_items | | | campaign.referral_program | | | campaign.referral_program.discount.apply_to_order | | | campaign.referral_program.discount.apply_to_items | | | campaign.referral_program.discount.apply_to_items_proportionally | | | campaign.referral_program.discount.apply_to_items_proportionally_by_quantity | | | campaign.referral_program.discount.fixed.apply_to_items | | | campaign.promotion | | | campaign.promotion.discount.apply_to_order | | | campaign.promotion.discount.apply_to_items | | | campaign.promotion.discount.apply_to_items_proportionally | | | campaign.promotion.discount.apply_to_items_proportionally_by_quantity | | | campaign.promotion.discount.fixed.apply_to_items | | | campaign.loyalty_program | | | campaign.lucky_draw | | | voucher.discount_voucher | | | voucher.discount_voucher.discount.apply_to_order | | | voucher.discount_voucher.discount.apply_to_items | | | voucher.discount_voucher.discount.apply_to_items_proportionally | | | voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity | | | voucher.discount_voucher.discount.fixed.apply_to_items | | | voucher.gift_voucher | | | voucher.gift_voucher.gift.apply_to_order | | | voucher.gift_voucher.gift.apply_to_items | | | voucher.loyalty_card | | | voucher.lucky_draw_code | | | distribution.custom_event | | | reward_assignment.pay_with_points | | | global | | + attr_accessor :context_type + + # Unique validation rule ID. + attr_accessor :id + + # Timestamp representing the date and time when the validation rule was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the validation rule was updated in ISO 8601 format. + attr_accessor :updated_at + + # The number of instances the validation rule has been assigned to different types of redeemables. + attr_accessor :assignments_count + + # The type of object represented by JSON. This object stores information about the validation rule. + attr_accessor :object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'rules' => :'rules', + :'error' => :'error', + :'applicable_to' => :'applicable_to', + :'type' => :'type', + :'context_type' => :'context_type', + :'id' => :'id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'assignments_count' => :'assignments_count', + :'object' => :'object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'rules' => :'Object', + :'error' => :'ValidationRuleBaseError', + :'applicable_to' => :'ValidationRuleBaseApplicableTo', + :'type' => :'String', + :'context_type' => :'String', + :'id' => :'String', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'assignments_count' => :'Integer', + :'object' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'ValidationRule' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationRulesUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationRulesUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + + if attributes.key?(:'rules') + self.rules = attributes[:'rules'] + else + self.rules = nil + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + else + self.applicable_to = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'expression' + end + + if attributes.key?(:'context_type') + self.context_type = attributes[:'context_type'] + else + self.context_type = 'global' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'assignments_count') + self.assignments_count = attributes[:'assignments_count'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'validation_rules' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @rules.nil? + invalid_properties.push('invalid value for "rules", rules cannot be nil.') + end + + if @applicable_to.nil? + invalid_properties.push('invalid value for "applicable_to", applicable_to cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @context_type.nil? + invalid_properties.push('invalid value for "context_type", context_type cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @name.nil? + return false if @rules.nil? + return false if @applicable_to.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + return false unless type_validator.valid?(@type) + return false if @context_type.nil? + context_type_validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + return false unless context_type_validator.valid?(@context_type) + return false if @id.nil? + return false if @created_at.nil? + return false if @object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["expression", "basic", "advanced", "complex"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] context_type Object to be assigned + def context_type=(context_type) + validator = EnumAttributeValidator.new('String', ["earning_rule.order.paid", "earning_rule.custom_event", "earning_rule.customer.segment.entered", "earning_rule.customer.tier.joined", "earning_rule.customer.tier.left", "earning_rule.customer.tier.upgraded", "earning_rule.customer.tier.downgraded", "earning_rule.customer.tier.prolonged", "campaign.discount_coupons", "campaign.discount_coupons.discount.apply_to_order", "campaign.discount_coupons.discount.apply_to_items", "campaign.discount_coupons.discount.apply_to_items_proportionally", "campaign.discount_coupons.discount.apply_to_items_proportionally_by_quantity", "campaign.discount_coupons.discount.apply_to_items_by_quantity", "campaign.discount_coupons.discount.fixed.apply_to_items", "campaign.discount_coupons.discount.percent.apply_to_items", "campaign.gift_vouchers", "campaign.gift_vouchers.gift.apply_to_order", "campaign.gift_vouchers.gift.apply_to_items", "campaign.referral_program", "campaign.referral_program.discount.apply_to_order", "campaign.referral_program.discount.apply_to_items", "campaign.referral_program.discount.apply_to_items_proportionally", "campaign.referral_program.discount.apply_to_items_proportionally_by_quantity", "campaign.referral_program.discount.apply_to_items_by_quantity", "campaign.referral_program.discount.fixed.apply_to_items", "campaign.referral_program.discount.percent.apply_to_items", "campaign.promotion", "campaign.promotion.discount.apply_to_order", "campaign.promotion.discount.apply_to_items", "campaign.promotion.discount.apply_to_items_proportionally", "campaign.promotion.discount.apply_to_items_proportionally_by_quantity", "campaign.promotion.discount.apply_to_items_by_quantity", "campaign.promotion.discount.fixed.apply_to_items", "campaign.promotion.discount.percent.apply_to_items", "campaign.loyalty_program", "campaign.lucky_draw", "voucher.discount_voucher", "voucher.discount_voucher.discount.apply_to_order", "voucher.discount_voucher.discount.apply_to_items", "voucher.discount_voucher.discount.apply_to_items_proportionally", "voucher.discount_voucher.discount.apply_to_items_proportionally_by_quantity", "voucher.discount_voucher.discount.apply_to_items_by_quantity", "voucher.discount_voucher.discount.fixed.apply_to_items", "voucher.discount_voucher.discount.percent.apply_to_items", "voucher.gift_voucher", "voucher.gift_voucher.gift.apply_to_order", "voucher.gift_voucher.gift.apply_to_items", "voucher.loyalty_card", "voucher.lucky_draw_code", "distribution.custom_event", "distribution.order.paid", "distribution.order.created", "distribution.order.canceled", "distribution.order.updated", "reward_assignment.pay_with_points", "global"]) + unless validator.valid?(context_type) + fail ArgumentError, "invalid value for \"context_type\", must be one of #{validator.allowable_values}." + end + @context_type = context_type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + rules == o.rules && + error == o.error && + applicable_to == o.applicable_to && + type == o.type && + context_type == o.context_type && + id == o.id && + created_at == o.created_at && + updated_at == o.updated_at && + assignments_count == o.assignments_count && + object == o.object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name, rules, error, applicable_to, type, context_type, id, created_at, updated_at, assignments_count, object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validations_redeemable_applicable.rb b/lib/VoucherifySdk/models/validations_redeemable_applicable.rb new file mode 100644 index 00000000..06df1785 --- /dev/null +++ b/lib/VoucherifySdk/models/validations_redeemable_applicable.rb @@ -0,0 +1,340 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ValidationsRedeemableApplicable + # Indicates whether the redeemable can be applied or not applied based on the validation rules. + attr_accessor :status + + # Redeemable ID, i.e. the voucher code. + attr_accessor :id + + # Redeemable's object type. + attr_accessor :object + + attr_accessor :order + + attr_accessor :applicable_to + + attr_accessor :inapplicable_to + + attr_accessor :result + + # The metadata object stores all custom attributes in the form of key/value pairs assigned to the redeemable. + attr_accessor :metadata + + attr_accessor :categories + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'id' => :'id', + :'object' => :'object', + :'order' => :'order', + :'applicable_to' => :'applicable_to', + :'inapplicable_to' => :'inapplicable_to', + :'result' => :'result', + :'metadata' => :'metadata', + :'categories' => :'categories' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'String', + :'id' => :'String', + :'object' => :'String', + :'order' => :'OrderCalculated', + :'applicable_to' => :'ApplicableToResultList', + :'inapplicable_to' => :'InapplicableToResultList', + :'result' => :'ValidationsRedeemableApplicableResult', + :'metadata' => :'Object', + :'categories' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationsRedeemableApplicable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationsRedeemableApplicable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'APPLICABLE' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'applicable_to') + self.applicable_to = attributes[:'applicable_to'] + end + + if attributes.key?(:'inapplicable_to') + self.inapplicable_to = attributes[:'inapplicable_to'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["APPLICABLE"]) + return false unless status_validator.valid?(@status) + object_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["APPLICABLE"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + id == o.id && + object == o.object && + order == o.order && + applicable_to == o.applicable_to && + inapplicable_to == o.inapplicable_to && + result == o.result && + metadata == o.metadata && + categories == o.categories + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, id, object, order, applicable_to, inapplicable_to, result, metadata, categories].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validations_redeemable_applicable_result.rb b/lib/VoucherifySdk/models/validations_redeemable_applicable_result.rb new file mode 100644 index 00000000..bb873cff --- /dev/null +++ b/lib/VoucherifySdk/models/validations_redeemable_applicable_result.rb @@ -0,0 +1,109 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Specifies the redeemable's end effect on the order. This object is unique to each type of redeemable. + module ValidationsRedeemableApplicableResult + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'RedeemableResultGiftCard', + :'RedeemableResultLoyaltyCard', + :'RedeemableResultPromotionStack', + :'RedeemableResultPromotionTier', + :'RedeemableResultVoucherCode' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/validations_redeemable_inapplicable.rb b/lib/VoucherifySdk/models/validations_redeemable_inapplicable.rb new file mode 100644 index 00000000..30a3c758 --- /dev/null +++ b/lib/VoucherifySdk/models/validations_redeemable_inapplicable.rb @@ -0,0 +1,292 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ValidationsRedeemableInapplicable + # Indicates whether the redeemable can be applied or not applied based on the validation rules. + attr_accessor :status + + # Redeemable ID, i.e. the voucher code. + attr_accessor :id + + # Redeemable's object type. + attr_accessor :object + + attr_accessor :result + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'id' => :'id', + :'object' => :'object', + :'result' => :'result' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'String', + :'id' => :'String', + :'object' => :'String', + :'result' => :'ValidationsRedeemableInapplicableResult' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationsRedeemableInapplicable` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationsRedeemableInapplicable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'INAPPLICABLE' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["INAPPLICABLE"]) + return false unless status_validator.valid?(@status) + object_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["INAPPLICABLE"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + id == o.id && + object == o.object && + result == o.result + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, id, object, result].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validations_redeemable_inapplicable_result.rb b/lib/VoucherifySdk/models/validations_redeemable_inapplicable_result.rb new file mode 100644 index 00000000..58923450 --- /dev/null +++ b/lib/VoucherifySdk/models/validations_redeemable_inapplicable_result.rb @@ -0,0 +1,214 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ValidationsRedeemableInapplicableResult + attr_accessor :error + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'error' => :'error' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'error' => :'Error' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationsRedeemableInapplicableResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationsRedeemableInapplicableResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + error == o.error + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [error].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validations_redeemable_skipped.rb b/lib/VoucherifySdk/models/validations_redeemable_skipped.rb new file mode 100644 index 00000000..9505fbe1 --- /dev/null +++ b/lib/VoucherifySdk/models/validations_redeemable_skipped.rb @@ -0,0 +1,292 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class ValidationsRedeemableSkipped + # Indicates whether the redeemable can be applied or not applied based on the validation rules. + attr_accessor :status + + # Redeemable ID, i.e. the voucher code. + attr_accessor :id + + # Redeemable's object type. + attr_accessor :object + + attr_accessor :result + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'id' => :'id', + :'object' => :'object', + :'result' => :'result' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'String', + :'id' => :'String', + :'object' => :'String', + :'result' => :'Object' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationsRedeemableSkipped` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationsRedeemableSkipped`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SKIPPED' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + status_validator = EnumAttributeValidator.new('String', ["SKIPPED"]) + return false unless status_validator.valid?(@status) + object_validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + return false unless object_validator.valid?(@object) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SKIPPED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["voucher", "promotion_tier"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + id == o.id && + object == o.object && + result == o.result + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, id, object, result].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validations_validate_all_response_body_redeemables_item.rb b/lib/VoucherifySdk/models/validations_validate_all_response_body_redeemables_item.rb new file mode 100644 index 00000000..e751f7d4 --- /dev/null +++ b/lib/VoucherifySdk/models/validations_validate_all_response_body_redeemables_item.rb @@ -0,0 +1,106 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module ValidationsValidateAllResponseBodyRedeemablesItem + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ValidationsRedeemableApplicable', + :'ValidationsRedeemableInapplicable', + :'ValidationsRedeemableSkipped' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/validations_validate_request_body.rb b/lib/VoucherifySdk/models/validations_validate_request_body.rb new file mode 100644 index 00000000..5b9970bc --- /dev/null +++ b/lib/VoucherifySdk/models/validations_validate_request_body.rb @@ -0,0 +1,316 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/validations`. + class ValidationsValidateRequestBody + # An array of redeemables. You can combine `voucher`(s) and `promotion_tier`(s). Alternatively, send one unique`promotion_stack` in the array. + attr_accessor :redeemables + + attr_accessor :order + + attr_accessor :customer + + attr_accessor :session + + # Is correspondent to Customer's source_id + attr_accessor :tracking_id + + # A set of key/value pairs that you can attach to a redemption object. It can be useful for storing additional information about the redemption in a structured format. + attr_accessor :metadata + + attr_accessor :options + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redeemables' => :'redeemables', + :'order' => :'order', + :'customer' => :'customer', + :'session' => :'session', + :'tracking_id' => :'tracking_id', + :'metadata' => :'metadata', + :'options' => :'options' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'redeemables' => :'Array', + :'order' => :'Order', + :'customer' => :'Customer', + :'session' => :'Session', + :'tracking_id' => :'String', + :'metadata' => :'Object', + :'options' => :'ClientValidationsValidateRequestBodyAllOfOptions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'StackableValidateRedeemBase' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationsValidateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationsValidateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + else + self.redeemables = nil + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + + if attributes.key?(:'session') + self.session = attributes[:'session'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemables.nil? + invalid_properties.push('invalid value for "redeemables", redeemables cannot be nil.') + end + + if @redeemables.length > 5 + invalid_properties.push('invalid value for "redeemables", number of items must be less than or equal to 5.') + end + + if @redeemables.length < 1 + invalid_properties.push('invalid value for "redeemables", number of items must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemables.nil? + return false if @redeemables.length > 5 + return false if @redeemables.length < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] redeemables Value to be assigned + def redeemables=(redeemables) + if redeemables.nil? + fail ArgumentError, 'redeemables cannot be nil' + end + + if redeemables.length > 5 + fail ArgumentError, 'invalid value for "redeemables", number of items must be less than or equal to 5.' + end + + if redeemables.length < 1 + fail ArgumentError, 'invalid value for "redeemables", number of items must be greater than or equal to 1.' + end + + @redeemables = redeemables + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redeemables == o.redeemables && + order == o.order && + customer == o.customer && + session == o.session && + tracking_id == o.tracking_id && + metadata == o.metadata && + options == o.options + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redeemables, order, customer, session, tracking_id, metadata, options].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/validations_validate_response_body.rb b/lib/VoucherifySdk/models/validations_validate_response_body.rb new file mode 100644 index 00000000..8f76457c --- /dev/null +++ b/lib/VoucherifySdk/models/validations_validate_response_body.rb @@ -0,0 +1,294 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for POST `/validations`. + class ValidationsValidateResponseBody + # The result of the validation. It takes all of the redeemables into account and returns a `false` if at least one redeemable is inapplicable. Returns `true` if all redeemables are applicable. + attr_accessor :valid + + # Lists validation results of each redeemable. If redeemables_application_mode=\"PARTIAL\" all redeemables here will be \"APPLICABLE\" + attr_accessor :redeemables + + # Lists validation results of each skipped redeemable. + attr_accessor :skipped_redeemables + + # Lists validation results of each inapplicable redeemable. + attr_accessor :inapplicable_redeemables + + attr_accessor :order + + # Hashed customer source ID. + attr_accessor :tracking_id + + attr_accessor :session + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'valid' => :'valid', + :'redeemables' => :'redeemables', + :'skipped_redeemables' => :'skipped_redeemables', + :'inapplicable_redeemables' => :'inapplicable_redeemables', + :'order' => :'order', + :'tracking_id' => :'tracking_id', + :'session' => :'session' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'valid' => :'Boolean', + :'redeemables' => :'Array', + :'skipped_redeemables' => :'Array', + :'inapplicable_redeemables' => :'Array', + :'order' => :'OrderCalculated', + :'tracking_id' => :'String', + :'session' => :'Session' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::ValidationsValidateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::ValidationsValidateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'valid') + self.valid = attributes[:'valid'] + else + self.valid = nil + end + + if attributes.key?(:'redeemables') + if (value = attributes[:'redeemables']).is_a?(Array) + self.redeemables = value + end + else + self.redeemables = nil + end + + if attributes.key?(:'skipped_redeemables') + if (value = attributes[:'skipped_redeemables']).is_a?(Array) + self.skipped_redeemables = value + end + end + + if attributes.key?(:'inapplicable_redeemables') + if (value = attributes[:'inapplicable_redeemables']).is_a?(Array) + self.inapplicable_redeemables = value + end + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'session') + self.session = attributes[:'session'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @valid.nil? + invalid_properties.push('invalid value for "valid", valid cannot be nil.') + end + + if @redeemables.nil? + invalid_properties.push('invalid value for "redeemables", redeemables cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @valid.nil? + return false if @redeemables.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + valid == o.valid && + redeemables == o.redeemables && + skipped_redeemables == o.skipped_redeemables && + inapplicable_redeemables == o.inapplicable_redeemables && + order == o.order && + tracking_id == o.tracking_id && + session == o.session + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [valid, redeemables, skipped_redeemables, inapplicable_redeemables, order, tracking_id, session].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher.rb b/lib/VoucherifySdk/models/voucher.rb new file mode 100644 index 00000000..1c632cfc --- /dev/null +++ b/lib/VoucherifySdk/models/voucher.rb @@ -0,0 +1,540 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing a voucher. + class Voucher + # Assigned by the Voucherify API, identifies the voucher. + attr_accessor :id + + # A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. + attr_accessor :code + + # A unique campaign name, identifies the voucher's parent campaign. + attr_accessor :campaign + + # Assigned by the Voucherify API, identifies the voucher's parent campaign. + attr_accessor :campaign_id + + # Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. + attr_accessor :category + + # Unique category ID assigned by Voucherify. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # Defines the type of the voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher + attr_accessor :active + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :assets + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Timestamp representing the date and time when the voucher was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique customer ID of voucher owner. + attr_accessor :holder_id + + attr_accessor :holder + + # The type of object represented by JSON. Default is `voucher`. + attr_accessor :object + + attr_accessor :distributions + + # Flag indicating whether this voucher is deleted. + attr_accessor :deleted + + attr_accessor :validation_rules_assignments + + attr_accessor :publish + + attr_accessor :redemption + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'category' => :'category', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'type' => :'type', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'active' => :'active', + :'additional_info' => :'additional_info', + :'metadata' => :'metadata', + :'assets' => :'assets', + :'is_referral_code' => :'is_referral_code', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'holder_id' => :'holder_id', + :'holder' => :'holder', + :'object' => :'object', + :'distributions' => :'distributions', + :'deleted' => :'deleted', + :'validation_rules_assignments' => :'validation_rules_assignments', + :'publish' => :'publish', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'campaign' => :'String', + :'campaign_id' => :'String', + :'category' => :'String', + :'category_id' => :'String', + :'categories' => :'Array', + :'type' => :'String', + :'discount' => :'Discount', + :'gift' => :'VoucherGift', + :'loyalty_card' => :'VoucherLoyaltyCard', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'VoucherValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'active' => :'Boolean', + :'additional_info' => :'String', + :'metadata' => :'Object', + :'assets' => :'VoucherAssets', + :'is_referral_code' => :'Boolean', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'holder_id' => :'String', + :'holder' => :'SimpleCustomer', + :'object' => :'String', + :'distributions' => :'Array', + :'deleted' => :'Boolean', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList', + :'publish' => :'VoucherPublish', + :'redemption' => :'VoucherRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'active', + :'is_referral_code', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::Voucher` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::Voucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'distributions') + if (value = attributes[:'distributions']).is_a?(Array) + self.distributions = value + end + end + + if attributes.key?(:'deleted') + self.deleted = attributes[:'deleted'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + + if attributes.key?(:'publish') + self.publish = attributes[:'publish'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + campaign == o.campaign && + campaign_id == o.campaign_id && + category == o.category && + category_id == o.category_id && + categories == o.categories && + type == o.type && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + active == o.active && + additional_info == o.additional_info && + metadata == o.metadata && + assets == o.assets && + is_referral_code == o.is_referral_code && + created_at == o.created_at && + updated_at == o.updated_at && + holder_id == o.holder_id && + holder == o.holder && + object == o.object && + distributions == o.distributions && + deleted == o.deleted && + validation_rules_assignments == o.validation_rules_assignments && + publish == o.publish && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, campaign, campaign_id, category, category_id, categories, type, discount, gift, loyalty_card, start_date, expiration_date, validity_timeframe, validity_day_of_week, active, additional_info, metadata, assets, is_referral_code, created_at, updated_at, holder_id, holder, object, distributions, deleted, validation_rules_assignments, publish, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_assets.rb b/lib/VoucherifySdk/models/voucher_assets.rb new file mode 100644 index 00000000..531f08c9 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_assets.rb @@ -0,0 +1,224 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores links to images of QR and barcode that correspond to an encrypted voucher code. + class VoucherAssets + attr_accessor :qr + + attr_accessor :barcode + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'qr' => :'qr', + :'barcode' => :'barcode' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'qr' => :'LoyaltiesMembersTransfersCreateResponseBodyAssetsQr', + :'barcode' => :'LoyaltiesMembersTransfersCreateResponseBodyAssetsBarcode' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherAssets` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherAssets`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'qr') + self.qr = attributes[:'qr'] + end + + if attributes.key?(:'barcode') + self.barcode = attributes[:'barcode'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + qr == o.qr && + barcode == o.barcode + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [qr, barcode].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_gift.rb b/lib/VoucherifySdk/models/voucher_gift.rb new file mode 100644 index 00000000..eb71ca68 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_gift.rb @@ -0,0 +1,270 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Object representing gift parameters. Child attributes are present only if `type` is `GIFT_VOUCHER`. Defaults to `null`. + class VoucherGift + # Total gift card income over the lifetime of the card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :amount + + # Available funds. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :balance + + # Defines how the credits are applied to the customer's order. + attr_accessor :effect + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'balance' => :'balance', + :'effect' => :'effect' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Integer', + :'balance' => :'Integer', + :'effect' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherGift` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherGift`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'effect') + self.effect = attributes[:'effect'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + effect_validator = EnumAttributeValidator.new('String', ["APPLY_TO_ORDER", "APPLY_TO_ITEMS"]) + return false unless effect_validator.valid?(@effect) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] effect Object to be assigned + def effect=(effect) + validator = EnumAttributeValidator.new('String', ["APPLY_TO_ORDER", "APPLY_TO_ITEMS"]) + unless validator.valid?(effect) + fail ArgumentError, "invalid value for \"effect\", must be one of #{validator.allowable_values}." + end + @effect = effect + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + balance == o.balance && + effect == o.effect + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, balance, effect].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_loyalty_card.rb b/lib/VoucherifySdk/models/voucher_loyalty_card.rb new file mode 100644 index 00000000..9a4c960b --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_loyalty_card.rb @@ -0,0 +1,246 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Object representing loyalty card parameters. Child attributes are present only if `type` is `LOYALTY_CARD`. Defaults to `null`. + class VoucherLoyaltyCard + # Total points incurred over lifespan of loyalty card. + attr_accessor :points + + # Points available for reward redemption. + attr_accessor :balance + + # The next closest date when the next set of points are due to expire. + attr_accessor :next_expiration_date + + # The amount of points that are set to expire next. + attr_accessor :next_expiration_points + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'points' => :'points', + :'balance' => :'balance', + :'next_expiration_date' => :'next_expiration_date', + :'next_expiration_points' => :'next_expiration_points' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'points' => :'Integer', + :'balance' => :'Integer', + :'next_expiration_date' => :'Date', + :'next_expiration_points' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherLoyaltyCard` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherLoyaltyCard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'points') + self.points = attributes[:'points'] + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'next_expiration_date') + self.next_expiration_date = attributes[:'next_expiration_date'] + end + + if attributes.key?(:'next_expiration_points') + self.next_expiration_points = attributes[:'next_expiration_points'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + points == o.points && + balance == o.balance && + next_expiration_date == o.next_expiration_date && + next_expiration_points == o.next_expiration_points + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [points, balance, next_expiration_date, next_expiration_points].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_publish.rb b/lib/VoucherifySdk/models/voucher_publish.rb new file mode 100644 index 00000000..e3bcf1d8 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_publish.rb @@ -0,0 +1,238 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This object stores a summary of publish events: an events counter and an endpoint which can be called to return details of each event. A publication is required for loyalty cards and referral codes. This object gets updated whenever a voucher has been published. Publication means assigning a code to a particular customer. Typically, a publication is made by distributing your codes to your customers, e.g. through Export to MailChimp or [publish voucher](ref:create-publication) API method. | Required | Optional | | -------- | :------: | | `type`:`LOYALTY_CARD` | `type`:`DISCOUNT_VOUCHER` | | `is_referral_code`:`true` | `type`:`GIFT_VOUCHER` | + class VoucherPublish + # The type of object represented is by default `list`. To get this list, you need to make a call to the endpoint returned in the `url` attribute. + attr_accessor :object + + # Publication events counter. + attr_accessor :count + + # The endpoint where this list of publications can be accessed using a GET method. `/v1/vouchers/{voucher_code}/publications` + attr_accessor :url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'count' => :'count', + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'count' => :'Integer', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherPublish` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherPublish`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'count') + self.count = attributes[:'count'] + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + count == o.count && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, count, url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_redemption.rb b/lib/VoucherifySdk/models/voucher_redemption.rb new file mode 100644 index 00000000..e5c0e52a --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_redemption.rb @@ -0,0 +1,268 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Stores a summary of redemptions that have been applied to the voucher. + class VoucherRedemption + # How many times a voucher can be redeemed. A `null` value means unlimited. + attr_accessor :quantity + + # How many times a voucher has already been redeemed. + attr_accessor :redeemed_quantity + + # Total amount redeemed. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 balance is written as 10000. + attr_accessor :redeemed_amount + + # Total loyalty points redeemed. + attr_accessor :redeemed_points + + # The type of object represented is by default `list`. To get this list, you need to make a call to the endpoint returned in the url attribute. + attr_accessor :object + + # The endpoint where this list of redemptions can be accessed using a GET method. `/v1/vouchers/{voucher_code}/redemptions` + attr_accessor :url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'quantity' => :'quantity', + :'redeemed_quantity' => :'redeemed_quantity', + :'redeemed_amount' => :'redeemed_amount', + :'redeemed_points' => :'redeemed_points', + :'object' => :'object', + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'quantity' => :'Integer', + :'redeemed_quantity' => :'Integer', + :'redeemed_amount' => :'Integer', + :'redeemed_points' => :'Integer', + :'object' => :'String', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + + if attributes.key?(:'redeemed_quantity') + self.redeemed_quantity = attributes[:'redeemed_quantity'] + end + + if attributes.key?(:'redeemed_amount') + self.redeemed_amount = attributes[:'redeemed_amount'] + end + + if attributes.key?(:'redeemed_points') + self.redeemed_points = attributes[:'redeemed_points'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + quantity == o.quantity && + redeemed_quantity == o.redeemed_quantity && + redeemed_amount == o.redeemed_amount && + redeemed_points == o.redeemed_points && + object == o.object && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [quantity, redeemed_quantity, redeemed_amount, redeemed_points, object, url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction.rb b/lib/VoucherifySdk/models/voucher_transaction.rb new file mode 100644 index 00000000..51ebfb76 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction.rb @@ -0,0 +1,379 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + class VoucherTransaction + # Unique transaction ID. + attr_accessor :id + + # The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. In case of a redemption, this value is null. + attr_accessor :source_id + + # Unique voucher ID. + attr_accessor :voucher_id + + # Unqiue campaign ID of the voucher's parent campaign if it is part of campaign that generates bulk codes. + attr_accessor :campaign_id + + # The channel through which the transaction took place, whether through the API or the the Dashboard. In case of a redemption, this value is null. + attr_accessor :source + + # Reason why the transaction occurred. In case of a redemption, this value is null. + attr_accessor :reason + + attr_accessor :type + + attr_accessor :details + + # The related transaction ID on the receiving card. + attr_accessor :related_transaction_id + + # Timestamp representing the date and time when the transaction was created in ISO 8601 format. + attr_accessor :created_at + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id', + :'voucher_id' => :'voucher_id', + :'campaign_id' => :'campaign_id', + :'source' => :'source', + :'reason' => :'reason', + :'type' => :'type', + :'details' => :'details', + :'related_transaction_id' => :'related_transaction_id', + :'created_at' => :'created_at' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String', + :'voucher_id' => :'String', + :'campaign_id' => :'String', + :'source' => :'String', + :'reason' => :'String', + :'type' => :'LoyaltyCardTransactionsType', + :'details' => :'VoucherTransactionDetails', + :'related_transaction_id' => :'String', + :'created_at' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'source_id', + :'source', + :'reason', + :'related_transaction_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransaction` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + + if attributes.key?(:'voucher_id') + self.voucher_id = attributes[:'voucher_id'] + else + self.voucher_id = nil + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + else + self.campaign_id = nil + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + else + self.reason = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'details') + self.details = attributes[:'details'] + else + self.details = nil + end + + if attributes.key?(:'related_transaction_id') + self.related_transaction_id = attributes[:'related_transaction_id'] + else + self.related_transaction_id = nil + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @voucher_id.nil? + invalid_properties.push('invalid value for "voucher_id", voucher_id cannot be nil.') + end + + if @campaign_id.nil? + invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @details.nil? + invalid_properties.push('invalid value for "details", details cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @voucher_id.nil? + return false if @campaign_id.nil? + return false if @type.nil? + return false if @details.nil? + return false if @created_at.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id && + voucher_id == o.voucher_id && + campaign_id == o.campaign_id && + source == o.source && + reason == o.reason && + type == o.type && + details == o.details && + related_transaction_id == o.related_transaction_id && + created_at == o.created_at + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id, voucher_id, campaign_id, source, reason, type, details, related_transaction_id, created_at].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details.rb b/lib/VoucherifySdk/models/voucher_transaction_details.rb new file mode 100644 index 00000000..dcef3b7d --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details.rb @@ -0,0 +1,323 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the detailed information about the transaction. + class VoucherTransactionDetails + attr_accessor :balance + + attr_accessor :order + + attr_accessor :event + + attr_accessor :earning_rule + + attr_accessor :segment + + attr_accessor :loyalty_tier + + attr_accessor :redemption + + attr_accessor :rollback + + attr_accessor :custom_event + + attr_accessor :event_schema + + attr_accessor :reward + + attr_accessor :source_voucher + + attr_accessor :destination_voucher + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'balance' => :'balance', + :'order' => :'order', + :'event' => :'event', + :'earning_rule' => :'earning_rule', + :'segment' => :'segment', + :'loyalty_tier' => :'loyalty_tier', + :'redemption' => :'redemption', + :'rollback' => :'rollback', + :'custom_event' => :'custom_event', + :'event_schema' => :'event_schema', + :'reward' => :'reward', + :'source_voucher' => :'source_voucher', + :'destination_voucher' => :'destination_voucher' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'balance' => :'VoucherTransactionDetailsBalance', + :'order' => :'VoucherTransactionDetailsOrder', + :'event' => :'VoucherTransactionDetailsEvent', + :'earning_rule' => :'VoucherTransactionDetailsEarningRule', + :'segment' => :'VoucherTransactionDetailsSegment', + :'loyalty_tier' => :'VoucherTransactionDetailsLoyaltyTier', + :'redemption' => :'VoucherTransactionDetailsRedemption', + :'rollback' => :'VoucherTransactionDetailsRollback', + :'custom_event' => :'VoucherTransactionDetailsCustomEvent', + :'event_schema' => :'VoucherTransactionDetailsEventSchema', + :'reward' => :'VoucherTransactionDetailsReward', + :'source_voucher' => :'SimpleVoucher', + :'destination_voucher' => :'SimpleVoucher' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetails` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + end + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'event') + self.event = attributes[:'event'] + end + + if attributes.key?(:'earning_rule') + self.earning_rule = attributes[:'earning_rule'] + end + + if attributes.key?(:'segment') + self.segment = attributes[:'segment'] + end + + if attributes.key?(:'loyalty_tier') + self.loyalty_tier = attributes[:'loyalty_tier'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + + if attributes.key?(:'rollback') + self.rollback = attributes[:'rollback'] + end + + if attributes.key?(:'custom_event') + self.custom_event = attributes[:'custom_event'] + end + + if attributes.key?(:'event_schema') + self.event_schema = attributes[:'event_schema'] + end + + if attributes.key?(:'reward') + self.reward = attributes[:'reward'] + end + + if attributes.key?(:'source_voucher') + self.source_voucher = attributes[:'source_voucher'] + end + + if attributes.key?(:'destination_voucher') + self.destination_voucher = attributes[:'destination_voucher'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + balance == o.balance && + order == o.order && + event == o.event && + earning_rule == o.earning_rule && + segment == o.segment && + loyalty_tier == o.loyalty_tier && + redemption == o.redemption && + rollback == o.rollback && + custom_event == o.custom_event && + event_schema == o.event_schema && + reward == o.reward && + source_voucher == o.source_voucher && + destination_voucher == o.destination_voucher + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [balance, order, event, earning_rule, segment, loyalty_tier, redemption, rollback, custom_event, event_schema, reward, source_voucher, destination_voucher].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_balance.rb b/lib/VoucherifySdk/models/voucher_transaction_details_balance.rb new file mode 100644 index 00000000..cb41c502 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_balance.rb @@ -0,0 +1,365 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information on how the balance was affected by the transaction. + class VoucherTransactionDetailsBalance + # The type of voucher whose balance is being adjusted due to the transaction. + attr_accessor :type + + # The available points prior to the transaction. + attr_accessor :total + + # The type of object represented by the JSON. + attr_accessor :object + + # The amount of points being used up in the transaction. + attr_accessor :points + + # The points balance on the loyalty card after the points in the transaction are subtracted from the loyalty card. + attr_accessor :balance + + attr_accessor :related_object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'total' => :'total', + :'object' => :'object', + :'points' => :'points', + :'balance' => :'balance', + :'related_object' => :'related_object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'total' => :'Integer', + :'object' => :'String', + :'points' => :'Integer', + :'balance' => :'Integer', + :'related_object' => :'VoucherTransactionDetailsBalanceRelatedObject' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsBalance` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsBalance`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'loyalty_card' + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'balance' + end + + if attributes.key?(:'points') + self.points = attributes[:'points'] + else + self.points = nil + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + else + self.balance = nil + end + + if attributes.key?(:'related_object') + self.related_object = attributes[:'related_object'] + else + self.related_object = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + pattern = Regexp.new(/loyalty_card/) + if @type !~ pattern + invalid_properties.push("invalid value for \"type\", must conform to the pattern #{pattern}.") + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + pattern = Regexp.new(/balance/) + if @object !~ pattern + invalid_properties.push("invalid value for \"object\", must conform to the pattern #{pattern}.") + end + + if @points.nil? + invalid_properties.push('invalid value for "points", points cannot be nil.') + end + + if @balance.nil? + invalid_properties.push('invalid value for "balance", balance cannot be nil.') + end + + if @related_object.nil? + invalid_properties.push('invalid value for "related_object", related_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["loyalty_card"]) + return false unless type_validator.valid?(@type) + return false if @type !~ Regexp.new(/loyalty_card/) + return false if @total.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["balance"]) + return false unless object_validator.valid?(@object) + return false if @object !~ Regexp.new(/balance/) + return false if @points.nil? + return false if @balance.nil? + return false if @related_object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["loyalty_card"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["balance"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + total == o.total && + object == o.object && + points == o.points && + balance == o.balance && + related_object == o.related_object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, total, object, points, balance, related_object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_balance_related_object.rb b/lib/VoucherifySdk/models/voucher_transaction_details_balance_related_object.rb new file mode 100644 index 00000000..241d1b6c --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_balance_related_object.rb @@ -0,0 +1,280 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the resource that is being modified with the values that are returned in the balance object. + class VoucherTransactionDetailsBalanceRelatedObject + # Identifies the voucher that is being modified, this is the ID that was assigned by the Voucherify API. + attr_accessor :id + + # The object being modified, i.e. voucher. + attr_accessor :type + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsBalanceRelatedObject` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsBalanceRelatedObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'voucher' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + pattern = Regexp.new(/voucher/) + if @type !~ pattern + invalid_properties.push("invalid value for \"type\", must conform to the pattern #{pattern}.") + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless type_validator.valid?(@type) + return false if @type !~ Regexp.new(/voucher/) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_custom_event.rb b/lib/VoucherifySdk/models/voucher_transaction_details_custom_event.rb new file mode 100644 index 00000000..1772ad3c --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_custom_event.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the custom event that triggers the point accrual. + class VoucherTransactionDetailsCustomEvent + # Unique event ID. + attr_accessor :id + + # Type of custom event. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsCustomEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsCustomEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @type.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_earning_rule.rb b/lib/VoucherifySdk/models/voucher_transaction_details_earning_rule.rb new file mode 100644 index 00000000..a1a707eb --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_earning_rule.rb @@ -0,0 +1,239 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the earning rule. + class VoucherTransactionDetailsEarningRule + # Unique earning rule ID. + attr_accessor :id + + attr_accessor :source + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source' => :'source' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source' => :'VoucherTransactionDetailsEarningRuleSource' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsEarningRule` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsEarningRule`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + else + self.source = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @source.nil? + invalid_properties.push('invalid value for "source", source cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @source.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source == o.source + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_earning_rule_source.rb b/lib/VoucherifySdk/models/voucher_transaction_details_earning_rule_source.rb new file mode 100644 index 00000000..a536d8a1 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_earning_rule_source.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the custom earning rule name. + class VoucherTransactionDetailsEarningRuleSource + # Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard. + attr_accessor :banner + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'banner' => :'banner' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'banner' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsEarningRuleSource` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsEarningRuleSource`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'banner') + self.banner = attributes[:'banner'] + else + self.banner = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @banner.nil? + invalid_properties.push('invalid value for "banner", banner cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @banner.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + banner == o.banner + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [banner].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_event.rb b/lib/VoucherifySdk/models/voucher_transaction_details_event.rb new file mode 100644 index 00000000..4b0574f1 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_event.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the event that triggers the point accrual. + class VoucherTransactionDetailsEvent + # Unique event ID. + attr_accessor :id + + # Type of event. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsEvent` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @type.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + type == o.type + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, type].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_event_schema.rb b/lib/VoucherifySdk/models/voucher_transaction_details_event_schema.rb new file mode 100644 index 00000000..34098af9 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_event_schema.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the custom event metadata schema. + class VoucherTransactionDetailsEventSchema + # Unique metadata schema ID. + attr_accessor :id + + # Type of custom event. + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsEventSchema` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsEventSchema`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_loyalty_tier.rb b/lib/VoucherifySdk/models/voucher_transaction_details_loyalty_tier.rb new file mode 100644 index 00000000..b334f89b --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_loyalty_tier.rb @@ -0,0 +1,238 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the loyalty tier. + class VoucherTransactionDetailsLoyaltyTier + attr_accessor :id + + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsLoyaltyTier` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsLoyaltyTier`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_order.rb b/lib/VoucherifySdk/models/voucher_transaction_details_order.rb new file mode 100644 index 00000000..b54901cf --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_order.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the original order. + class VoucherTransactionDetailsOrder + # Unique order ID. + attr_accessor :id + + # The merchant’s order ID if it is different from the Voucherify order ID. It is really useful in case of integration between multiple systems. It can be an order ID from CRM, database or 3rd party service. + attr_accessor :source_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'source_id' => :'source_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'source_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsOrder` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsOrder`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + else + self.source_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @source_id.nil? + invalid_properties.push('invalid value for "source_id", source_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @source_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + source_id == o.source_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, source_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_redemption.rb b/lib/VoucherifySdk/models/voucher_transaction_details_redemption.rb new file mode 100644 index 00000000..4bd3c2d0 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_redemption.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the original redemption. + class VoucherTransactionDetailsRedemption + # Unique redemption ID. + attr_accessor :id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsRedemption` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsRedemption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_reward.rb b/lib/VoucherifySdk/models/voucher_transaction_details_reward.rb new file mode 100644 index 00000000..989d1043 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_reward.rb @@ -0,0 +1,240 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the pay with points reward. + class VoucherTransactionDetailsReward + # Unique reward ID. + attr_accessor :id + + # Reward name. + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsReward` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsReward`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_rollback.rb b/lib/VoucherifySdk/models/voucher_transaction_details_rollback.rb new file mode 100644 index 00000000..5d057532 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_rollback.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the redemption rollback. + class VoucherTransactionDetailsRollback + # Unique redemption rollback ID. + attr_accessor :id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsRollback` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsRollback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transaction_details_segment.rb b/lib/VoucherifySdk/models/voucher_transaction_details_segment.rb new file mode 100644 index 00000000..8adbd0b8 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transaction_details_segment.rb @@ -0,0 +1,238 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains information about the segment. + class VoucherTransactionDetailsSegment + attr_accessor :id + + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionDetailsSegment` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionDetailsSegment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + else + self.name = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transactions_export.rb b/lib/VoucherifySdk/models/voucher_transactions_export.rb new file mode 100644 index 00000000..8c53429f --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transactions_export.rb @@ -0,0 +1,407 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # This is an object representing an export. Using this endpoint, you can export voucher transactions as a CSV file. This functionality works asynchronously and comes down to the following steps: create an export object and return its id so you can track its status, trigger a CSV file generation, change the status to SCHEDULED when the generation is over, store the file in S3 and change the status to DONE. Now you can download it. With parameters you can select which fields will be exported. An export request will almost always result in a single file being generated by the system. However, when your volume of data is large, the system may split the results into multiple chunks. + class VoucherTransactionsExport + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the `export`. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # The type of exported object. + attr_accessor :exported_object + + attr_accessor :parameters + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the `channel` value is `WEBSITE`. + attr_accessor :user_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters', + :'result' => :'result', + :'user_id' => :'user_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'exported_object' => :'String', + :'parameters' => :'VoucherTransactionsFilters', + :'result' => :'VoucherTransactionsExportResult', + :'user_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionsExport` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionsExport`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = 'API' + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher_transactions' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + else + self.parameters = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + if @parameters.nil? + invalid_properties.push('invalid value for "parameters", parameters cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @channel.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + return false unless exported_object_validator.valid?(@exported_object) + return false if @parameters.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + exported_object == o.exported_object && + parameters == o.parameters && + result == o.result && + user_id == o.user_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, exported_object, parameters, result, user_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions.rb b/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions.rb new file mode 100644 index 00000000..d2672184 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions.rb @@ -0,0 +1,222 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Filter condition. + class VoucherTransactionsExportFilterConditions + attr_accessor :voucher_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'voucher_id' => :'voucher_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'voucher_id' => :'VoucherTransactionsExportFilterConditionsVoucherId' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionsExportFilterConditions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionsExportFilterConditions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'voucher_id') + self.voucher_id = attributes[:'voucher_id'] + else + self.voucher_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @voucher_id.nil? + invalid_properties.push('invalid value for "voucher_id", voucher_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @voucher_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + voucher_id == o.voucher_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [voucher_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id.rb b/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id.rb new file mode 100644 index 00000000..c21643e7 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id.rb @@ -0,0 +1,222 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Data filters used to narrow the data records to be returned in the result. + class VoucherTransactionsExportFilterConditionsVoucherId + attr_accessor :conditions + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'conditions' => :'conditions' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'conditions' => :'VoucherTransactionsExportFilterConditionsVoucherIdConditions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherId` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'conditions') + self.conditions = attributes[:'conditions'] + else + self.conditions = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @conditions.nil? + invalid_properties.push('invalid value for "conditions", conditions cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @conditions.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + conditions == o.conditions + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [conditions].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id_conditions.rb b/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id_conditions.rb new file mode 100644 index 00000000..ad73fcd3 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transactions_export_filter_conditions_voucher_id_conditions.rb @@ -0,0 +1,252 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Data filters used to narrow the data records to be returned in the result. + class VoucherTransactionsExportFilterConditionsVoucherIdConditions + attr_accessor :_in + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_in' => :'$in' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'_in' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherIdConditions` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionsExportFilterConditionsVoucherIdConditions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'_in') + if (value = attributes[:'_in']).is_a?(Array) + self._in = value + end + else + self._in = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @_in.nil? + invalid_properties.push('invalid value for "_in", _in cannot be nil.') + end + + if @_in.length > 1 + invalid_properties.push('invalid value for "_in", number of items must be less than or equal to 1.') + end + + if @_in.length < 1 + invalid_properties.push('invalid value for "_in", number of items must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @_in.nil? + return false if @_in.length > 1 + return false if @_in.length < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] _in Value to be assigned + def _in=(_in) + if _in.nil? + fail ArgumentError, '_in cannot be nil' + end + + if _in.length > 1 + fail ArgumentError, 'invalid value for "_in", number of items must be less than or equal to 1.' + end + + if _in.length < 1 + fail ArgumentError, 'invalid value for "_in", number of items must be greater than or equal to 1.' + end + + @_in = _in + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _in == o._in + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [_in].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transactions_export_parameters.rb b/lib/VoucherifySdk/models/voucher_transactions_export_parameters.rb new file mode 100644 index 00000000..b0671830 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transactions_export_parameters.rb @@ -0,0 +1,262 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with a gift card or loyalty card transactions export along with the sorting order of the returned data. + class VoucherTransactionsExportParameters + # How the export is filtered, where the dash `-` preceding a sorting option means sorting in a descending order. + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields: | **Field** | **Definition** | **Example Export** | |:---|:---|:---| | id | Unique transaction ID. | vtx_0cb7811f1c07765800 | | type | Transaction type. | - `CREDITS_REMOVAL`
- `CREDITS_ADDITION`
- `CREDITS_REFUND`
- `CREDITS_REDEMPTION`
- `POINTS_ACCRUAL`
- `POINTS_CANCELLATION`
- `POINTS_REDEMPTION`
- `POINTS_REFUND`
- `POINTS_ADDITION`
- `POINTS_REMOVAL`
- `POINTS_EXPIRATION`
- `POINTS_TRANSFER_IN`
- `POINTS_TRANSFER_OUT` | | source_id | Unique transaction source ID. | 8638 | | reason | Contains the reason for the transaction if one was included originally. | | | balance | The gift card or loyalty card balance after the transaction. | | | amount | The amount of gift card or loyalty card credits being allocated during the transaction. This value can either be negative or positive depending on the nature of the transaction. | | | created_at | Timestamp in ISO 8601 format representing the date and time when the transaction was created. | 2022-03-09T09:16:32.521Z | | voucher_id | Unique Voucher ID. | v_dky7ksKfPX50Wb2Bxvcoeb1xT20b6tcp | | campaign_id | Parent campaign ID. | camp_FNYR4jhqZBM9xTptxDGgeNBV | | source| Channel through which the transaction was initiated. | API | | details | More detailed information stored in the form of a JSON. | Provides more details related to the transaction in the form of an object. | | related_transaction_id | Unique transaction ID related to a receiver/donor card in the case of a points transfer from/to another card. | vtx_0c9afe802593b34b80 | + attr_accessor :fields + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'String', + :'fields' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionsExportParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionsExportParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + order_validator = EnumAttributeValidator.new('String', ["-created_at", "created_at"]) + return false unless order_validator.valid?(@order) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] order Object to be assigned + def order=(order) + validator = EnumAttributeValidator.new('String', ["-created_at", "created_at"]) + unless validator.valid?(order) + fail ArgumentError, "invalid value for \"order\", must be one of #{validator.allowable_values}." + end + @order = order + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transactions_export_result.rb b/lib/VoucherifySdk/models/voucher_transactions_export_result.rb new file mode 100644 index 00000000..7c277479 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transactions_export_result.rb @@ -0,0 +1,223 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Contains the URL of the CSV file. + class VoucherTransactionsExportResult + # URL of the CSV file location. It contains the `token` used for authorization in the [Download export](ref:download-export) method. + attr_accessor :url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionsExportResult` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionsExportResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'url') + self.url = attributes[:'url'] + else + self.url = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @url.nil? + invalid_properties.push('invalid value for "url", url cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @url.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_transactions_filters.rb b/lib/VoucherifySdk/models/voucher_transactions_filters.rb new file mode 100644 index 00000000..f1205db6 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_transactions_filters.rb @@ -0,0 +1,278 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # List of available fields and filters that can be exported with gift card or loyalty card transactions along with the sorting order of the returned data. + class VoucherTransactionsFilters + # How the export is filtered, where the dash `-` preceding a sorting option means sorting in a descending order. + attr_accessor :order + + # Array of strings containing the data in the export. These fields define the headers in the CSV file. The array can be a combination of any of the following available fields: | **Field** | **Definition** | **Example Export** | |:---|:---|:---| | id | Unique transaction ID. | vtx_0cb7811f1c07765800 | | type | Transaction type. | - `CREDITS_REMOVAL`
- `CREDITS_ADDITION`
- `CREDITS_REFUND`
- `CREDITS_REDEMPTION`
- `POINTS_ACCRUAL`
- `POINTS_CANCELLATION`
- `POINTS_REDEMPTION`
- `POINTS_REFUND`
- `POINTS_ADDITION`
- `POINTS_REMOVAL`
- `POINTS_EXPIRATION`
- `POINTS_TRANSFER_IN`
- `POINTS_TRANSFER_OUT` | | source_id | Unique transaction source ID. | 8638 | | reason | Contains the reason for the transaction if one was included originally. | | | balance | The gift card or loyalty card balance after the transaction. | | | amount | The amount of gift card or loyalty card credits being allocated during the transaction. This value can either be negative or positive depending on the nature of the transaction. | | | created_at | Timestamp in ISO 8601 format representing the date and time when the transaction was created. | 2022-03-09T09:16:32.521Z | | voucher_id | Unique Voucher ID. | v_dky7ksKfPX50Wb2Bxvcoeb1xT20b6tcp | | campaign_id | Parent campaign ID. | camp_FNYR4jhqZBM9xTptxDGgeNBV | | source| Channel through which the transaction was initiated. | API | | details | More detailed information stored in the form of a JSON. | Provides more details related to the transaction in the form of an object. | | related_transaction_id | Unique transaction ID related to a receiver/donor card in the case of a points transfer from/to another card. | vtx_0c9afe802593b34b80 | + attr_accessor :fields + + attr_accessor :filters + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order' => :'order', + :'fields' => :'fields', + :'filters' => :'filters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'order' => :'String', + :'fields' => :'Array', + :'filters' => :'VoucherTransactionsExportFilterConditions' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherTransactionsFilters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherTransactionsFilters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'order') + self.order = attributes[:'order'] + end + + if attributes.key?(:'fields') + if (value = attributes[:'fields']).is_a?(Array) + self.fields = value + end + end + + if attributes.key?(:'filters') + self.filters = attributes[:'filters'] + else + self.filters = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @filters.nil? + invalid_properties.push('invalid value for "filters", filters cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + order_validator = EnumAttributeValidator.new('String', ["-created_at", "created_at"]) + return false unless order_validator.valid?(@order) + return false if @filters.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] order Object to be assigned + def order=(order) + validator = EnumAttributeValidator.new('String', ["-created_at", "created_at"]) + unless validator.valid?(order) + fail ArgumentError, "invalid value for \"order\", must be one of #{validator.allowable_values}." + end + @order = order + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order == o.order && + fields == o.fields && + filters == o.filters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order, fields, filters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/voucher_validity_timeframe.rb b/lib/VoucherifySdk/models/voucher_validity_timeframe.rb new file mode 100644 index 00000000..31475cd0 --- /dev/null +++ b/lib/VoucherifySdk/models/voucher_validity_timeframe.rb @@ -0,0 +1,226 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Set recurrent time periods when the voucher is valid. For example, valid for 1 hour every other day.`start_date` **required** when including the `validity_timeframe`. + class VoucherValidityTimeframe + # Defines the amount of time the voucher will be active in ISO 8601 format. For example, a voucher with a `duration` of `PT1H` will be valid for a duration of one hour. + attr_accessor :duration + + # Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, a voucher with an `interval` of `P2D` will be active every other day. + attr_accessor :interval + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'duration' => :'duration', + :'interval' => :'interval' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'duration' => :'String', + :'interval' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VoucherValidityTimeframe` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VoucherValidityTimeframe`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'interval') + self.interval = attributes[:'interval'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + duration == o.duration && + interval == o.interval + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [duration, interval].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_balance_update_request_body.rb b/lib/VoucherifySdk/models/vouchers_balance_update_request_body.rb new file mode 100644 index 00000000..efed8f2f --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_balance_update_request_body.rb @@ -0,0 +1,243 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for `vouchers/{code}/balance`. + class VouchersBalanceUpdateRequestBody + # The incremental amount to be added to or removed from the current balance on the gift card or loyalty card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. To remove balance, simply add a minus sign before the value, i.e. to remove $20, use -2000. + attr_accessor :amount + + # The merchant’s transaction ID if it is different from the Voucherify transaction ID. It is really useful in case of an integration between multiple systems. It can be a transaction ID from a CRM system, database or 3rd-party service. + attr_accessor :source_id + + # Reason why the transaction occurred. + attr_accessor :reason + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'source_id' => :'source_id', + :'reason' => :'reason' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Integer', + :'source_id' => :'String', + :'reason' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersBalanceUpdateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersBalanceUpdateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + + if attributes.key?(:'source_id') + self.source_id = attributes[:'source_id'] + end + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @amount.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + source_id == o.source_id && + reason == o.reason + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, source_id, reason].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_balance_update_response_body.rb b/lib/VoucherifySdk/models/vouchers_balance_update_response_body.rb new file mode 100644 index 00000000..d8285de4 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_balance_update_response_body.rb @@ -0,0 +1,381 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for `vouchers/{code}/balance.` + class VouchersBalanceUpdateResponseBody + # The incremental amount added (positive integer) or subtracted (negative integer) to the current balance on the gift card or loyalty card. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :amount + + # Total income incurred over the lifespan of the gift card or loyalty card. + attr_accessor :total + + # The balance after adding or subtracting a specified amount. Value is multiplied by 100 to precisely represent 2 decimal places. For example, $100 amount is written as 10000. + attr_accessor :balance + + # The type of voucher being modified. + attr_accessor :type + + attr_accessor :operation_type + + # The type of object represented by JSON. Default is `balance`. + attr_accessor :object + + attr_accessor :related_object + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'total' => :'total', + :'balance' => :'balance', + :'type' => :'type', + :'operation_type' => :'operation_type', + :'object' => :'object', + :'related_object' => :'related_object' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Integer', + :'total' => :'Integer', + :'balance' => :'Integer', + :'type' => :'String', + :'operation_type' => :'String', + :'object' => :'String', + :'related_object' => :'VouchersBalanceUpdateResponseBodyRelatedObject' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersBalanceUpdateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersBalanceUpdateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'balance') + self.balance = attributes[:'balance'] + else + self.balance = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'operation_type') + self.operation_type = attributes[:'operation_type'] + else + self.operation_type = 'MANUAL' + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'balance' + end + + if attributes.key?(:'related_object') + self.related_object = attributes[:'related_object'] + else + self.related_object = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @amount.nil? + invalid_properties.push('invalid value for "amount", amount cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @balance.nil? + invalid_properties.push('invalid value for "balance", balance cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @operation_type.nil? + invalid_properties.push('invalid value for "operation_type", operation_type cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @related_object.nil? + invalid_properties.push('invalid value for "related_object", related_object cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @amount.nil? + return false if @total.nil? + return false if @balance.nil? + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["gift_voucher", "loyalty_card"]) + return false unless type_validator.valid?(@type) + return false if @operation_type.nil? + operation_type_validator = EnumAttributeValidator.new('String', ["MANUAL"]) + return false unless operation_type_validator.valid?(@operation_type) + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["balance"]) + return false unless object_validator.valid?(@object) + return false if @related_object.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["gift_voucher", "loyalty_card"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] operation_type Object to be assigned + def operation_type=(operation_type) + validator = EnumAttributeValidator.new('String', ["MANUAL"]) + unless validator.valid?(operation_type) + fail ArgumentError, "invalid value for \"operation_type\", must be one of #{validator.allowable_values}." + end + @operation_type = operation_type + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["balance"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + total == o.total && + balance == o.balance && + type == o.type && + operation_type == o.operation_type && + object == o.object && + related_object == o.related_object + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, total, balance, type, operation_type, object, related_object].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_balance_update_response_body_related_object.rb b/lib/VoucherifySdk/models/vouchers_balance_update_response_body_related_object.rb new file mode 100644 index 00000000..b50159a0 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_balance_update_response_body_related_object.rb @@ -0,0 +1,274 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Defines the resource that is being modified with the values that are returned in the balance object. + class VouchersBalanceUpdateResponseBodyRelatedObject + # The object being modified, i.e. `voucher`. + attr_accessor :type + + # Identifies the voucher that is being modified, this is the ID that was assigned by the Voucherify API. + attr_accessor :id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersBalanceUpdateResponseBodyRelatedObject` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersBalanceUpdateResponseBodyRelatedObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'voucher' + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + type_validator = EnumAttributeValidator.new('String', ["voucher"]) + return false unless type_validator.valid?(@type) + return false if @id.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["voucher"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_disable_response_body.rb b/lib/VoucherifySdk/models/vouchers_disable_response_body.rb new file mode 100644 index 00000000..21212271 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_disable_response_body.rb @@ -0,0 +1,547 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/vouchers/{code}/disable`. + class VouchersDisableResponseBody + # Assigned by the Voucherify API, identifies the voucher. + attr_accessor :id + + # A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. + attr_accessor :code + + # A unique campaign name, identifies the voucher's parent campaign. + attr_accessor :campaign + + # Assigned by the Voucherify API, identifies the voucher's parent campaign. + attr_accessor :campaign_id + + # Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. + attr_accessor :category + + # Unique category ID assigned by Voucherify. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # Defines the type of the voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher + attr_accessor :active + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :assets + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Timestamp representing the date and time when the voucher was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique customer ID of voucher owner. + attr_accessor :holder_id + + attr_accessor :holder + + # The type of object represented by JSON. Default is `voucher`. + attr_accessor :object + + attr_accessor :distributions + + # Flag indicating whether this voucher is deleted. + attr_accessor :deleted + + attr_accessor :validation_rules_assignments + + attr_accessor :publish + + attr_accessor :redemption + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'category' => :'category', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'type' => :'type', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'active' => :'active', + :'additional_info' => :'additional_info', + :'metadata' => :'metadata', + :'assets' => :'assets', + :'is_referral_code' => :'is_referral_code', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'holder_id' => :'holder_id', + :'holder' => :'holder', + :'object' => :'object', + :'distributions' => :'distributions', + :'deleted' => :'deleted', + :'validation_rules_assignments' => :'validation_rules_assignments', + :'publish' => :'publish', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'campaign' => :'String', + :'campaign_id' => :'String', + :'category' => :'String', + :'category_id' => :'String', + :'categories' => :'Array', + :'type' => :'String', + :'discount' => :'Discount', + :'gift' => :'VoucherGift', + :'loyalty_card' => :'VoucherLoyaltyCard', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'VoucherValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'active' => :'Boolean', + :'additional_info' => :'String', + :'metadata' => :'Object', + :'assets' => :'VoucherAssets', + :'is_referral_code' => :'Boolean', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'holder_id' => :'String', + :'holder' => :'SimpleCustomer', + :'object' => :'String', + :'distributions' => :'Array', + :'deleted' => :'Boolean', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList', + :'publish' => :'VoucherPublish', + :'redemption' => :'VoucherRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'active', + :'is_referral_code', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Voucher' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersDisableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersDisableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'distributions') + if (value = attributes[:'distributions']).is_a?(Array) + self.distributions = value + end + end + + if attributes.key?(:'deleted') + self.deleted = attributes[:'deleted'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + + if attributes.key?(:'publish') + self.publish = attributes[:'publish'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + campaign == o.campaign && + campaign_id == o.campaign_id && + category == o.category && + category_id == o.category_id && + categories == o.categories && + type == o.type && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + active == o.active && + additional_info == o.additional_info && + metadata == o.metadata && + assets == o.assets && + is_referral_code == o.is_referral_code && + created_at == o.created_at && + updated_at == o.updated_at && + holder_id == o.holder_id && + holder == o.holder && + object == o.object && + distributions == o.distributions && + deleted == o.deleted && + validation_rules_assignments == o.validation_rules_assignments && + publish == o.publish && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, campaign, campaign_id, category, category_id, categories, type, discount, gift, loyalty_card, start_date, expiration_date, validity_timeframe, validity_day_of_week, active, additional_info, metadata, assets, is_referral_code, created_at, updated_at, holder_id, holder, object, distributions, deleted, validation_rules_assignments, publish, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_enable_response_body.rb b/lib/VoucherifySdk/models/vouchers_enable_response_body.rb new file mode 100644 index 00000000..fa207a2a --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_enable_response_body.rb @@ -0,0 +1,547 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/vouchers/{code}/enable`. + class VouchersEnableResponseBody + # Assigned by the Voucherify API, identifies the voucher. + attr_accessor :id + + # A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. + attr_accessor :code + + # A unique campaign name, identifies the voucher's parent campaign. + attr_accessor :campaign + + # Assigned by the Voucherify API, identifies the voucher's parent campaign. + attr_accessor :campaign_id + + # Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. + attr_accessor :category + + # Unique category ID assigned by Voucherify. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # Defines the type of the voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher + attr_accessor :active + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :assets + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Timestamp representing the date and time when the voucher was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique customer ID of voucher owner. + attr_accessor :holder_id + + attr_accessor :holder + + # The type of object represented by JSON. Default is `voucher`. + attr_accessor :object + + attr_accessor :distributions + + # Flag indicating whether this voucher is deleted. + attr_accessor :deleted + + attr_accessor :validation_rules_assignments + + attr_accessor :publish + + attr_accessor :redemption + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'category' => :'category', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'type' => :'type', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'active' => :'active', + :'additional_info' => :'additional_info', + :'metadata' => :'metadata', + :'assets' => :'assets', + :'is_referral_code' => :'is_referral_code', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'holder_id' => :'holder_id', + :'holder' => :'holder', + :'object' => :'object', + :'distributions' => :'distributions', + :'deleted' => :'deleted', + :'validation_rules_assignments' => :'validation_rules_assignments', + :'publish' => :'publish', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'campaign' => :'String', + :'campaign_id' => :'String', + :'category' => :'String', + :'category_id' => :'String', + :'categories' => :'Array', + :'type' => :'String', + :'discount' => :'Discount', + :'gift' => :'VoucherGift', + :'loyalty_card' => :'VoucherLoyaltyCard', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'VoucherValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'active' => :'Boolean', + :'additional_info' => :'String', + :'metadata' => :'Object', + :'assets' => :'VoucherAssets', + :'is_referral_code' => :'Boolean', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'holder_id' => :'String', + :'holder' => :'SimpleCustomer', + :'object' => :'String', + :'distributions' => :'Array', + :'deleted' => :'Boolean', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList', + :'publish' => :'VoucherPublish', + :'redemption' => :'VoucherRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'active', + :'is_referral_code', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Voucher' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersEnableResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersEnableResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'distributions') + if (value = attributes[:'distributions']).is_a?(Array) + self.distributions = value + end + end + + if attributes.key?(:'deleted') + self.deleted = attributes[:'deleted'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + + if attributes.key?(:'publish') + self.publish = attributes[:'publish'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + campaign == o.campaign && + campaign_id == o.campaign_id && + category == o.category && + category_id == o.category_id && + categories == o.categories && + type == o.type && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + active == o.active && + additional_info == o.additional_info && + metadata == o.metadata && + assets == o.assets && + is_referral_code == o.is_referral_code && + created_at == o.created_at && + updated_at == o.updated_at && + holder_id == o.holder_id && + holder == o.holder && + object == o.object && + distributions == o.distributions && + deleted == o.deleted && + validation_rules_assignments == o.validation_rules_assignments && + publish == o.publish && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, campaign, campaign_id, category, category_id, categories, type, discount, gift, loyalty_card, start_date, expiration_date, validity_timeframe, validity_day_of_week, active, additional_info, metadata, assets, is_referral_code, created_at, updated_at, holder_id, holder, object, distributions, deleted, validation_rules_assignments, publish, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_get_response_body.rb b/lib/VoucherifySdk/models/vouchers_get_response_body.rb new file mode 100644 index 00000000..4a665ff2 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_get_response_body.rb @@ -0,0 +1,547 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/vouchers/{code}`. + class VouchersGetResponseBody + # Assigned by the Voucherify API, identifies the voucher. + attr_accessor :id + + # A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters. + attr_accessor :code + + # A unique campaign name, identifies the voucher's parent campaign. + attr_accessor :campaign + + # Assigned by the Voucherify API, identifies the voucher's parent campaign. + attr_accessor :campaign_id + + # Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint. + attr_accessor :category + + # Unique category ID assigned by Voucherify. + attr_accessor :category_id + + # Contains details about the category. + attr_accessor :categories + + # Defines the type of the voucher. + attr_accessor :type + + attr_accessor :discount + + attr_accessor :gift + + attr_accessor :loyalty_card + + # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date. + attr_accessor :start_date + + # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date. + attr_accessor :expiration_date + + attr_accessor :validity_timeframe + + # Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday + attr_accessor :validity_day_of_week + + # A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the `start_date` and `expiration_date`. - `true` indicates an *active* voucher - `false` indicates an *inactive* voucher + attr_accessor :active + + # An optional field to keep any extra textual information about the code such as a code description and details. + attr_accessor :additional_info + + # The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format. + attr_accessor :metadata + + attr_accessor :assets + + # Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`. + attr_accessor :is_referral_code + + # Timestamp representing the date and time when the voucher was created in ISO 8601 format. + attr_accessor :created_at + + # Timestamp representing the date and time when the voucher was last updated in ISO 8601 format. + attr_accessor :updated_at + + # Unique customer ID of voucher owner. + attr_accessor :holder_id + + attr_accessor :holder + + # The type of object represented by JSON. Default is `voucher`. + attr_accessor :object + + attr_accessor :distributions + + # Flag indicating whether this voucher is deleted. + attr_accessor :deleted + + attr_accessor :validation_rules_assignments + + attr_accessor :publish + + attr_accessor :redemption + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'code' => :'code', + :'campaign' => :'campaign', + :'campaign_id' => :'campaign_id', + :'category' => :'category', + :'category_id' => :'category_id', + :'categories' => :'categories', + :'type' => :'type', + :'discount' => :'discount', + :'gift' => :'gift', + :'loyalty_card' => :'loyalty_card', + :'start_date' => :'start_date', + :'expiration_date' => :'expiration_date', + :'validity_timeframe' => :'validity_timeframe', + :'validity_day_of_week' => :'validity_day_of_week', + :'active' => :'active', + :'additional_info' => :'additional_info', + :'metadata' => :'metadata', + :'assets' => :'assets', + :'is_referral_code' => :'is_referral_code', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'holder_id' => :'holder_id', + :'holder' => :'holder', + :'object' => :'object', + :'distributions' => :'distributions', + :'deleted' => :'deleted', + :'validation_rules_assignments' => :'validation_rules_assignments', + :'publish' => :'publish', + :'redemption' => :'redemption' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'code' => :'String', + :'campaign' => :'String', + :'campaign_id' => :'String', + :'category' => :'String', + :'category_id' => :'String', + :'categories' => :'Array', + :'type' => :'String', + :'discount' => :'Discount', + :'gift' => :'VoucherGift', + :'loyalty_card' => :'VoucherLoyaltyCard', + :'start_date' => :'Time', + :'expiration_date' => :'Time', + :'validity_timeframe' => :'VoucherValidityTimeframe', + :'validity_day_of_week' => :'Array', + :'active' => :'Boolean', + :'additional_info' => :'String', + :'metadata' => :'Object', + :'assets' => :'VoucherAssets', + :'is_referral_code' => :'Boolean', + :'created_at' => :'Time', + :'updated_at' => :'Time', + :'holder_id' => :'String', + :'holder' => :'SimpleCustomer', + :'object' => :'String', + :'distributions' => :'Array', + :'deleted' => :'Boolean', + :'validation_rules_assignments' => :'ValidationRulesAssignmentsList', + :'publish' => :'VoucherPublish', + :'redemption' => :'VoucherRedemption' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'active', + :'is_referral_code', + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'Voucher' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'campaign') + self.campaign = attributes[:'campaign'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'category_id') + self.category_id = attributes[:'category_id'] + end + + if attributes.key?(:'categories') + if (value = attributes[:'categories']).is_a?(Array) + self.categories = value + end + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'discount') + self.discount = attributes[:'discount'] + end + + if attributes.key?(:'gift') + self.gift = attributes[:'gift'] + end + + if attributes.key?(:'loyalty_card') + self.loyalty_card = attributes[:'loyalty_card'] + end + + if attributes.key?(:'start_date') + self.start_date = attributes[:'start_date'] + end + + if attributes.key?(:'expiration_date') + self.expiration_date = attributes[:'expiration_date'] + end + + if attributes.key?(:'validity_timeframe') + self.validity_timeframe = attributes[:'validity_timeframe'] + end + + if attributes.key?(:'validity_day_of_week') + if (value = attributes[:'validity_day_of_week']).is_a?(Array) + self.validity_day_of_week = value + end + end + + if attributes.key?(:'active') + self.active = attributes[:'active'] + end + + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'assets') + self.assets = attributes[:'assets'] + end + + if attributes.key?(:'is_referral_code') + self.is_referral_code = attributes[:'is_referral_code'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'holder_id') + self.holder_id = attributes[:'holder_id'] + end + + if attributes.key?(:'holder') + self.holder = attributes[:'holder'] + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'voucher' + end + + if attributes.key?(:'distributions') + if (value = attributes[:'distributions']).is_a?(Array) + self.distributions = value + end + end + + if attributes.key?(:'deleted') + self.deleted = attributes[:'deleted'] + end + + if attributes.key?(:'validation_rules_assignments') + self.validation_rules_assignments = attributes[:'validation_rules_assignments'] + end + + if attributes.key?(:'publish') + self.publish = attributes[:'publish'] + end + + if attributes.key?(:'redemption') + self.redemption = attributes[:'redemption'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + type_validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + return false unless type_validator.valid?(@type) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] type Object to be assigned + def type=(type) + validator = EnumAttributeValidator.new('String', ["GIFT_VOUCHER", "DISCOUNT_VOUCHER", "LOYALTY_CARD"]) + unless validator.valid?(type) + fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}." + end + @type = type + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + code == o.code && + campaign == o.campaign && + campaign_id == o.campaign_id && + category == o.category && + category_id == o.category_id && + categories == o.categories && + type == o.type && + discount == o.discount && + gift == o.gift && + loyalty_card == o.loyalty_card && + start_date == o.start_date && + expiration_date == o.expiration_date && + validity_timeframe == o.validity_timeframe && + validity_day_of_week == o.validity_day_of_week && + active == o.active && + additional_info == o.additional_info && + metadata == o.metadata && + assets == o.assets && + is_referral_code == o.is_referral_code && + created_at == o.created_at && + updated_at == o.updated_at && + holder_id == o.holder_id && + holder == o.holder && + object == o.object && + distributions == o.distributions && + deleted == o.deleted && + validation_rules_assignments == o.validation_rules_assignments && + publish == o.publish && + redemption == o.redemption + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, code, campaign, campaign_id, category, category_id, categories, type, discount, gift, loyalty_card, start_date, expiration_date, validity_timeframe, validity_day_of_week, active, additional_info, metadata, assets, is_referral_code, created_at, updated_at, holder_id, holder, object, distributions, deleted, validation_rules_assignments, publish, redemption].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_import_csv_create_response_body.rb b/lib/VoucherifySdk/models/vouchers_import_csv_create_response_body.rb new file mode 100644 index 00000000..c0197590 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_import_csv_create_response_body.rb @@ -0,0 +1,230 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/vouchers/importCSV`. + class VouchersImportCsvCreateResponseBody + # The ID of the scheduled asynchronous action. + attr_accessor :async_action_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'async_action_id' => :'async_action_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'async_action_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'AsyncActions' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersImportCsvCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersImportCsvCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'async_action_id') + self.async_action_id = attributes[:'async_action_id'] + else + self.async_action_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @async_action_id.nil? + invalid_properties.push('invalid value for "async_action_id", async_action_id cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @async_action_id.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + async_action_id == o.async_action_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [async_action_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_redemption_get_response_body.rb b/lib/VoucherifySdk/models/vouchers_redemption_get_response_body.rb new file mode 100644 index 00000000..6242c346 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_redemption_get_response_body.rb @@ -0,0 +1,323 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/vouchers/{code}/redemption`. + class VouchersRedemptionGetResponseBody + # The maximum number of times a voucher can be redeemed. + attr_accessor :quantity + + # The number of times the voucher was redeemed successfully. + attr_accessor :redeemed_quantity + + # The type of object represented by JSON. This object stores information about redemptions in a dictionary. + attr_accessor :object + + # URL + attr_accessor :url + + # Identifies the name of the attribute that contains the array of `redemption_entries`. + attr_accessor :data_ref + + # Total number of redemption objects. + attr_accessor :total + + # Contains the array of successful and failed redemption objects. + attr_accessor :redemption_entries + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'quantity' => :'quantity', + :'redeemed_quantity' => :'redeemed_quantity', + :'object' => :'object', + :'url' => :'url', + :'data_ref' => :'data_ref', + :'total' => :'total', + :'redemption_entries' => :'redemption_entries' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'quantity' => :'Integer', + :'redeemed_quantity' => :'Integer', + :'object' => :'String', + :'url' => :'String', + :'data_ref' => :'String', + :'total' => :'Integer', + :'redemption_entries' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'quantity', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersRedemptionGetResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersRedemptionGetResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end + + if attributes.key?(:'redeemed_quantity') + self.redeemed_quantity = attributes[:'redeemed_quantity'] + else + self.redeemed_quantity = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + else + self.url = nil + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'redemption_entries' + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + else + self.total = nil + end + + if attributes.key?(:'redemption_entries') + if (value = attributes[:'redemption_entries']).is_a?(Array) + self.redemption_entries = value + end + else + self.redemption_entries = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @redeemed_quantity.nil? + invalid_properties.push('invalid value for "redeemed_quantity", redeemed_quantity cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @url.nil? + invalid_properties.push('invalid value for "url", url cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @total.nil? + invalid_properties.push('invalid value for "total", total cannot be nil.') + end + + if @redemption_entries.nil? + invalid_properties.push('invalid value for "redemption_entries", redemption_entries cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @redeemed_quantity.nil? + return false if @object.nil? + return false if @url.nil? + return false if @data_ref.nil? + return false if @total.nil? + return false if @redemption_entries.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + quantity == o.quantity && + redeemed_quantity == o.redeemed_quantity && + object == o.object && + url == o.url && + data_ref == o.data_ref && + total == o.total && + redemption_entries == o.redemption_entries + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [quantity, redeemed_quantity, object, url, data_ref, total, redemption_entries].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_redemption_get_response_body_redemption_entries_item.rb b/lib/VoucherifySdk/models/vouchers_redemption_get_response_body_redemption_entries_item.rb new file mode 100644 index 00000000..480a1ab3 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_redemption_get_response_body_redemption_entries_item.rb @@ -0,0 +1,105 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + module VouchersRedemptionGetResponseBodyRedemptionEntriesItem + class << self + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'Redemption', + :'RedemptionRollback' + ] + end + + # Builds the object + # @param [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + openapi_one_of.include?(:AnyType) ? data : nil + end + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = VoucherifySdk.const_get(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + # raise if data contains keys that are not known to the model + raise unless (data.keys - const.acceptable_attributes).empty? + model = const.build_from_hash(data) + return model if model + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_transactions_export_create_request_body.rb b/lib/VoucherifySdk/models/vouchers_transactions_export_create_request_body.rb new file mode 100644 index 00000000..dfc009a3 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_transactions_export_create_request_body.rb @@ -0,0 +1,215 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Request body schema for **POST** `/vouchers/transactions/export`. + class VouchersTransactionsExportCreateRequestBody + attr_accessor :parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'parameters' => :'parameters' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'parameters' => :'VoucherTransactionsExportParameters' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersTransactionsExportCreateRequestBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersTransactionsExportCreateRequestBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + parameters == o.parameters + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [parameters].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_transactions_export_create_response_body.rb b/lib/VoucherifySdk/models/vouchers_transactions_export_create_response_body.rb new file mode 100644 index 00000000..341f31e6 --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_transactions_export_create_response_body.rb @@ -0,0 +1,414 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **POST** `/vouchers/{code}/transactions/export`. + class VouchersTransactionsExportCreateResponseBody + # Unique export ID. + attr_accessor :id + + # The type of object being represented. This object stores information about the `export`. + attr_accessor :object + + # Timestamp representing the date and time when the export was scheduled in ISO 8601 format. + attr_accessor :created_at + + # Status of the export. Informs you whether the export has already been completed, i.e. indicates whether the file containing the exported data has been generated. + attr_accessor :status + + # The channel through which the export was triggered. + attr_accessor :channel + + # The type of exported object. + attr_accessor :exported_object + + attr_accessor :parameters + + attr_accessor :result + + # Identifies the specific user who initiated the export through the Voucherify Dashboard; returned when the `channel` value is `WEBSITE`. + attr_accessor :user_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'object' => :'object', + :'created_at' => :'created_at', + :'status' => :'status', + :'channel' => :'channel', + :'exported_object' => :'exported_object', + :'parameters' => :'parameters', + :'result' => :'result', + :'user_id' => :'user_id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'object' => :'String', + :'created_at' => :'Time', + :'status' => :'String', + :'channel' => :'String', + :'exported_object' => :'String', + :'parameters' => :'VoucherTransactionsFilters', + :'result' => :'VoucherTransactionsExportResult', + :'user_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'result', + :'user_id' + ]) + end + + # List of class defined in allOf (OpenAPI v3) + def self.openapi_all_of + [ + :'VoucherTransactionsExport' + ] + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersTransactionsExportCreateResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersTransactionsExportCreateResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'export' + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + else + self.created_at = nil + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'SCHEDULED' + end + + if attributes.key?(:'channel') + self.channel = attributes[:'channel'] + else + self.channel = 'API' + end + + if attributes.key?(:'exported_object') + self.exported_object = attributes[:'exported_object'] + else + self.exported_object = 'voucher_transactions' + end + + if attributes.key?(:'parameters') + self.parameters = attributes[:'parameters'] + else + self.parameters = nil + end + + if attributes.key?(:'result') + self.result = attributes[:'result'] + else + self.result = nil + end + + if attributes.key?(:'user_id') + self.user_id = attributes[:'user_id'] + else + self.user_id = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @status.nil? + invalid_properties.push('invalid value for "status", status cannot be nil.') + end + + if @channel.nil? + invalid_properties.push('invalid value for "channel", channel cannot be nil.') + end + + if @exported_object.nil? + invalid_properties.push('invalid value for "exported_object", exported_object cannot be nil.') + end + + if @parameters.nil? + invalid_properties.push('invalid value for "parameters", parameters cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @object.nil? + object_validator = EnumAttributeValidator.new('String', ["export"]) + return false unless object_validator.valid?(@object) + return false if @created_at.nil? + return false if @status.nil? + status_validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + return false unless status_validator.valid?(@status) + return false if @channel.nil? + return false if @exported_object.nil? + exported_object_validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + return false unless exported_object_validator.valid?(@exported_object) + return false if @parameters.nil? + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] object Object to be assigned + def object=(object) + validator = EnumAttributeValidator.new('String', ["export"]) + unless validator.valid?(object) + fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}." + end + @object = object + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ["SCHEDULED"]) + unless validator.valid?(status) + fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}." + end + @status = status + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] exported_object Object to be assigned + def exported_object=(exported_object) + validator = EnumAttributeValidator.new('String', ["voucher_transactions"]) + unless validator.valid?(exported_object) + fail ArgumentError, "invalid value for \"exported_object\", must be one of #{validator.allowable_values}." + end + @exported_object = exported_object + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + object == o.object && + created_at == o.created_at && + status == o.status && + channel == o.channel && + exported_object == o.exported_object && + parameters == o.parameters && + result == o.result && + user_id == o.user_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, object, created_at, status, channel, exported_object, parameters, result, user_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/models/vouchers_transactions_list_response_body.rb b/lib/VoucherifySdk/models/vouchers_transactions_list_response_body.rb new file mode 100644 index 00000000..7898b13b --- /dev/null +++ b/lib/VoucherifySdk/models/vouchers_transactions_list_response_body.rb @@ -0,0 +1,276 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +require 'date' +require 'time' + +module VoucherifySdk + # Response body schema for **GET** `/vouchers/{code}/transactions`. + class VouchersTransactionsListResponseBody + # The type of object represented by JSON. + attr_accessor :object + + # Identifies the name of the attribute that contains the array of transaction objects. + attr_accessor :data_ref + + # A dictionary that contains an array of transactions. Each entry in the array is a separate transaction object. + attr_accessor :data + + # As query results are always limited (by the limit parameter), the `has_more` flag indicates whether there are more records for given filter parameters. This let's you know if you are able to run another request (with a different page or a different start date filter) to get more records returned in the results. + attr_accessor :has_more + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'object' => :'object', + :'data_ref' => :'data_ref', + :'data' => :'data', + :'has_more' => :'has_more' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'object' => :'String', + :'data_ref' => :'String', + :'data' => :'Array', + :'has_more' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::VouchersTransactionsListResponseBody` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::VouchersTransactionsListResponseBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'object') + self.object = attributes[:'object'] + else + self.object = 'list' + end + + if attributes.key?(:'data_ref') + self.data_ref = attributes[:'data_ref'] + else + self.data_ref = 'data' + end + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + else + self.data = nil + end + + if attributes.key?(:'has_more') + self.has_more = attributes[:'has_more'] + else + self.has_more = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @object.nil? + invalid_properties.push('invalid value for "object", object cannot be nil.') + end + + if @data_ref.nil? + invalid_properties.push('invalid value for "data_ref", data_ref cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + if @has_more.nil? + invalid_properties.push('invalid value for "has_more", has_more cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @object.nil? + return false if @data_ref.nil? + return false if @data.nil? + return false if @has_more.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + object == o.object && + data_ref == o.data_ref && + data == o.data && + has_more == o.has_more + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [object, data_ref, data, has_more].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = VoucherifySdk.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/VoucherifySdk/version.rb b/lib/VoucherifySdk/version.rb new file mode 100644 index 00000000..2439bfe6 --- /dev/null +++ b/lib/VoucherifySdk/version.rb @@ -0,0 +1,15 @@ +=begin +#Voucherify API + +#Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. + +The version of the OpenAPI document: v2018-08-01 +Contact: support@voucherify.io +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.1 + +=end + +module VoucherifySdk + VERSION = '5.0.0' +end diff --git a/lib/voucherify.rb b/lib/voucherify.rb deleted file mode 100644 index fab815f9..00000000 --- a/lib/voucherify.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'voucherify/version' -require 'voucherify/client' -require 'voucherify/service/async_actions' -require 'voucherify/service/campaigns' -require 'voucherify/service/customers' -require 'voucherify/service/distributions' -require 'voucherify/service/events' -require 'voucherify/service/loyalties' -require 'voucherify/service/orders' -require 'voucherify/service/products' -require 'voucherify/service/redemptions' -require 'voucherify/service/promotions' -require 'voucherify/service/rewards' -require 'voucherify/service/segments' -require 'voucherify/service/segments' -require 'voucherify/service/validation_rules' -require 'voucherify/service/validations' -require 'voucherify/service/vouchers' -require 'voucherify/service/consents' -require 'voucherify/utils' - -module Voucherify -end diff --git a/lib/voucherify/client.rb b/lib/voucherify/client.rb deleted file mode 100644 index 270c2c4b..00000000 --- a/lib/voucherify/client.rb +++ /dev/null @@ -1,154 +0,0 @@ -require 'uri' -require 'rest-client' -require 'json' - -module Voucherify - - class Client - attr_reader :backend_url - - def initialize (options) - @options = options - @backend_url = (@options[:apiUrl] || @options['apiUrl'] || 'https://api.voucherify.io') + '/v1' - @headers = { - 'X-App-Id' => @options[:applicationId] || @options['applicationId'], - 'X-App-Token' => @options[:clientSecretKey] || @options['clientSecretKey'], - 'X-Voucherify-Channel' => 'Ruby-SDK', - 'X-Voucherify-API-Version' => @options[:apiVersion] || @options['apiVersion'] || 'v2018-08-01', - :accept => :json, - }.reject{ |k,v| v.nil? } - @timeout = @options[:timeout] || @options['timeout'] - end - - def async_actions - Voucherify::Service::AsyncActions.new(self) - end - - def vouchers - Voucherify::Service::Vouchers.new(self) - end - - def distributions - Voucherify::Service::Distributions.new(self) - end - - def validations - Voucherify::Service::Validations.new(self) - end - - def redemptions - Voucherify::Service::Redemptions.new(self) - end - - def customers - Voucherify::Service::Customers.new(self) - end - - def products - Voucherify::Service::Products.new(self) - end - - def campaigns - Voucherify::Service::Campaigns.new(self) - end - - def validation_rules - Voucherify::Service::ValidationRules.new(self) - end - - def segments - Voucherify::Service::Segments.new(self) - end - - def events - Voucherify::Service::Events.new(self) - end - - def promotions - Voucherify::Service::Promotions.new(self) - end - - def orders - Voucherify::Service::Orders.new(self) - end - - def rewards - Voucherify::Service::Rewards.new(self) - end - - def loyalties - Voucherify::Service::Loyalties.new(self) - end - - def consents - Voucherify::Service::Consents.new(self) - end - - def get(path, params = {}) - begin - url = @backend_url + path - response = RestClient::Request::execute(method: :get, url: url, headers: @headers.merge({:params => params}), read_timeout: @timeout, open_timeout: @timeout) - JSON.parse(response.body) - rescue RestClient::Exception => e - raise VoucherifyError.new(e) - end - end - - def put(path, body, params = {}) - begin - url = @backend_url + path - response = RestClient::Request::execute(method: :put, url: url, payload: body, headers: @headers.merge({:params => params, :content_type => :json}), read_timeout: @timeout, open_timeout: @timeout) - JSON.parse(response.body) - rescue RestClient::Exception => e - raise VoucherifyError.new(e) - end - end - - def post(path, body, params = {}) - begin - url = @backend_url + path - response = RestClient::Request::execute(method: :post, url: url, payload: body, headers: @headers.merge({:params => params, :content_type => :json}), read_timeout: @timeout, open_timeout: @timeout) - if !response.body.empty? - JSON.parse(response.body) - else - nil - end - rescue RestClient::Exception => e - raise VoucherifyError.new(e) - end - end - - def delete(path, params = {}) - begin - url = @backend_url + path - RestClient::Request::execute(method: :delete, url: url, headers: @headers.merge({:params => params}), read_timeout: @timeout, open_timeout: @timeout) - nil - rescue RestClient::Exception => e - raise VoucherifyError.new(e) - end - end - end - - class VoucherifyError < RuntimeError - attr_reader :response - attr_reader :code - attr_reader :details - attr_reader :key - - def initialize (restClientError) - if restClientError.is_a? RestClient::Exceptions::Timeout - @response = restClientError - @details = restClientError - super(restClientError) - else - @response = restClientError.response - parsedResponse = JSON.parse(@response) - @code = parsedResponse['code'] - @details = parsedResponse['details'] - @key = parsedResponse['key'] - super(parsedResponse['message']) - end - end - end - -end diff --git a/lib/voucherify/service/async_actions.rb b/lib/voucherify/service/async_actions.rb deleted file mode 100644 index 4e3956f9..00000000 --- a/lib/voucherify/service/async_actions.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class AsyncActions - attr_reader :client - - def initialize(client) - @client = client - end - - def get(id) - @client.get("/async-actions/#{ERB::Util.url_encode(id)}") - end - - def list(query) - @client.get('/async-actions', query) - end - - end - end -end \ No newline at end of file diff --git a/lib/voucherify/service/campaigns.rb b/lib/voucherify/service/campaigns.rb deleted file mode 100644 index cc1549be..00000000 --- a/lib/voucherify/service/campaigns.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Campaigns - attr_reader :client - - def initialize(client) - @client = client - end - - def create(campaign) - @client.post('/campaigns', campaign.to_json) - end - - def get(campaign_name) - @client.get("/campaigns/#{ERB::Util.url_encode(campaign_name)}") - end - - def delete(campaign_name, params = {}) - @client.delete("/campaigns/#{ERB::Util.url_encode(campaign_name)}", {:force => (!!(params['force'] || params[:force])).to_s}) - nil - end - - def add_voucher(campaign_name, params = {}) - code = params['code'] || params[:code] - url = "/campaigns/#{ERB::Util.url_encode(campaign_name)}/vouchers" - url += "/#{ERB::Util.url_encode(code)}" if code - params.delete 'code' - params.delete :code - @client.post(url, params.to_json) - end - - def import_vouchers(campaign_name, vouchers) - @client.post("/campaigns/#{ERB::Util.url_encode(campaign_name)}/import", vouchers.to_json) - end - end - end -end \ No newline at end of file diff --git a/lib/voucherify/service/consents.rb b/lib/voucherify/service/consents.rb deleted file mode 100644 index 9d67b31f..00000000 --- a/lib/voucherify/service/consents.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Consents - attr_reader :client - - def initialize(client) - @client = client - end - - def get() - @client.get('/consents') - end - end - end -end diff --git a/lib/voucherify/service/customers.rb b/lib/voucherify/service/customers.rb deleted file mode 100644 index 71cdab35..00000000 --- a/lib/voucherify/service/customers.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'erb' - -module Voucherify - module Service - class Customers - attr_reader :client - - def initialize(client) - @client = client - end - - def list(params = {}) - @client.get('/customers', params) - end - - def create(customer) - @client.post('/customers', customer.to_json) - end - - def get(customer_id) - @client.get("/customers/#{ERB::Util.url_encode(customer_id)}") - end - - def update(customer) - @client.put("/customers/#{ERB::Util.url_encode(customer['id'] || customer[:id])}", customer.to_json) - end - - def delete(customer_id) - @client.delete("/customers/#{ERB::Util.url_encode(customer_id)}") - end - - def update_consents(customer_id, consents) - @client.put("/customers/#{ERB::Util.url_encode(customer_id)}/consents", consents.to_json) - end - end - end -end diff --git a/lib/voucherify/service/distributions.rb b/lib/voucherify/service/distributions.rb deleted file mode 100644 index 2ae52c2e..00000000 --- a/lib/voucherify/service/distributions.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Distributions - attr_reader :client - - def initialize(client) - @client = client - end - - def publish(params) - payload = {} - if params.is_a? String - payload = {:campaign => params} - elsif params.is_a? Hash - payload = params - end - - @client.post('/vouchers/publish', payload.to_json) - end - - def create_export(export) - @client.post('/exports', export) - end - - def get_export(id) - @client.get("/exports/#{ERB::Util.url_encode(id)}") - end - - def delete_export(id) - @client.delete("/exports/#{ERB::Util.url_encode(id)}") - end - - def list_publications(params = {}) - @client.get('/publications', params) - end - - def create_publication(params) - @client.post('/publications', params.to_json) - end - - end - end -end diff --git a/lib/voucherify/service/events.rb b/lib/voucherify/service/events.rb deleted file mode 100644 index 6c78edf9..00000000 --- a/lib/voucherify/service/events.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Voucherify - module Service - class Events - attr_reader :client - - def initialize(client) - @client = client - end - - def track(event, metadata, customer, referral = nil) - @client.post('/events', { - :event => event, - :metadata => metadata, - :customer => customer, - :referral => referral - }.to_json) - end - - def track_event(event) - @client.post('/events', event.to_json) - end - end - end -end diff --git a/lib/voucherify/service/loyalties.rb b/lib/voucherify/service/loyalties.rb deleted file mode 100644 index 7de737fe..00000000 --- a/lib/voucherify/service/loyalties.rb +++ /dev/null @@ -1,133 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Loyalties - attr_reader :client - - def initialize(client) - @client = client - end - - def earning_rules - Voucherify::Service::LoyaltyEarningRules.new(@client) - end - - def reward_assignments - Voucherify::Service::LoyaltyRewards.new(@client) - end - - def members - Voucherify::Service::LoyaltyMembers.new(@client) - end - - def list(query = {}) - @client.get('/loyalties', query) - end - - def create(loyalty) - @client.post("/loyalties", loyalty.to_json) - end - - def update(loyalty_id, loyalty) - @client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}", loyalty.to_json) - end - - def get(loyalty_id) - @client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}") - end - - def delete(loyalty_id, query = {}) - @client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}", query) - nil - end - end - - class LoyaltyEarningRules - attr_reader :client - - def initialize(client) - @client = client - end - - def list(loyalty_id, query = {}) - @client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules", query) - end - - def create(loyalty_id, earning_rules) - payload = earning_rules - if earning_rules.is_a? Hash - payload = [ earning_rules ] - end - @client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules", payload.to_json) - end - - def update(loyalty_id, earning_rule_id, earning_rule) - @client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules/#{ERB::Util.url_encode(earning_rule_id)}", earning_rule.to_json) - end - - def delete(loyalty_id, earning_rule_id) - @client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules/#{ERB::Util.url_encode(earning_rule_id)}") - nil - end - end - - class LoyaltyRewards - attr_reader :client - - def initialize(client) - @client = client - end - - def list(loyalty_id, query = {}) - @client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", query) - end - - def create(loyalty_id, assignments) - payload = assignments - if assignments.is_a? Hash - payload = [ assignments ] - end - @client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", payload.to_json) - end - - def update(loyalty_id, assignment_id, assignment) - @client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}", assignment.to_json) - end - - def delete(loyalty_id, assignment_id) - @client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}") - nil - end - end - - class LoyaltyMembers - attr_reader :client - - def initialize(client) - @client = client - end - - def list(loyalty_id, query = {}) - @client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members", query) - end - - def add(loyalty_id, member) - @client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members", member.to_json) - end - - def get(loyalty_id, member_id) - @client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}") - end - - def add_balance(loyalty_id, member_id, payload) - @client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}/balance", payload.to_json) - end - - def redeem_reward(loyalty_id, member_id, payload) - @client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}/redemption", payload.to_json) - end - end - - end -end diff --git a/lib/voucherify/service/orders.rb b/lib/voucherify/service/orders.rb deleted file mode 100644 index 3061c695..00000000 --- a/lib/voucherify/service/orders.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Orders - attr_reader :client - - def initialize(client) - @client = client - end - - def create(order) - @client.post('/orders', order.to_json) - end - - def get(order_id) - @client.get("/orders/#{ERB::Util.url_encode(order_id)}") - end - - def update(order_id, order) - @client.put("/orders/#{ERB::Util.url_encode(order_id)}", order.to_json) - end - - def list(query = {}) - @client.get("/orders", query) - end - end - end -end diff --git a/lib/voucherify/service/products.rb b/lib/voucherify/service/products.rb deleted file mode 100644 index 665743a9..00000000 --- a/lib/voucherify/service/products.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Products - attr_reader :client - - def initialize(client) - @client = client - end - - def create(product) - @client.post('/products', product.to_json) - end - - def get(product_id) - @client.get("/products/#{ERB::Util.url_encode(product_id)}") - end - - def update(product) - @client.put("/products/#{ERB::Util.url_encode(product['id'] || product[:id])}", product.to_json) - end - - def delete(product_id) - @client.delete("/products/#{ERB::Util.url_encode(product_id)}") - end - - def list(query = {}) - @client.get('/products', query) - end - - def create_sku(product_id, sku) - @client.post("/products/#{ERB::Util.url_encode(product_id)}/skus", sku.to_json) - end - - def get_sku(product_id, sku_id) - @client.get("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}") - end - - def update_sku(product_id, sku) - @client.put("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku['id'] || sku[:id])}", sku.to_json) - end - - def delete_sku(product_id, sku_id) - @client.delete("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}") - end - - def list_skus(product_id) - @client.get("/products/#{ERB::Util.url_encode(product_id)}/skus") - end - end - end -end \ No newline at end of file diff --git a/lib/voucherify/service/promotions.rb b/lib/voucherify/service/promotions.rb deleted file mode 100644 index 68a46317..00000000 --- a/lib/voucherify/service/promotions.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Promotions - attr_reader :client - - def initialize(client) - @client = client - end - - def create(campaign) - @client.campaigns.create(campaign) - end - - def validate(validation_context) - @client.post('/promotions/validation', validation_context.to_json) - end - - def tiers - Voucherify::Service::PromotionTiers.new(@client) - end - end - - class PromotionTiers - attr_reader :client - - def initialize(client) - @client = client - end - - def list(promotion_id) - @client.get("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers") - end - - def create(promotion_id, promotion_tier) - @client.post("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers", promotion_tier.to_json) - end - - def redeem(promotions_tier_id, redemption_context) - @client.post("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}/redemption", redemption_context.to_json) - end - - def update(promotions_tier) - @client.put("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier['id'] || promotions_tier[:id])}", promotions_tier.to_json) - end - - def delete(promotions_tier_id) - @client.delete("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}") - nil - end - - def list_tiers(query = {}) - @client.get("/promotions/tiers", query) - end - end - end -end diff --git a/lib/voucherify/service/redemptions.rb b/lib/voucherify/service/redemptions.rb deleted file mode 100644 index d49961c7..00000000 --- a/lib/voucherify/service/redemptions.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Redemptions - attr_reader :client - - def initialize(client) - @client = client - end - - def redeem(code, params = {}) - if code.is_a? Hash - endpoint = "/promotions/tiers/#{ERB::Util.url_encode(code[:id] || code['id'])}/redemption" - else - endpoint = "/vouchers/#{ERB::Util.url_encode(code)}/redemption" - end - @client.post(endpoint, params.to_json) - end - - def list(query = {}) - @client.get('/redemptions', query) - end - - def get_for_voucher(code) - @client.get("/vouchers/#{ERB::Util.url_encode(code)}/redemption") - end - - def rollback(redemption_id, payload = {}) - reason = payload['reason'] || payload[:reason] - params = reason ? {:reason => reason} : {} - payload.delete 'reason' - payload.delete :reason - @client.post("/redemptions/#{ERB::Util.url_encode(redemption_id)}/rollback", payload.to_json, params) - end - - def get_redemption(redemption_id) - @client.get("/redemptions/#{ERB::Util.url_encode(redemption_id)}") - end - end - end -end diff --git a/lib/voucherify/service/rewards.rb b/lib/voucherify/service/rewards.rb deleted file mode 100644 index 7dae9140..00000000 --- a/lib/voucherify/service/rewards.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Rewards - attr_reader :client - - def initialize(client) - @client = client - end - - def assignments - Voucherify::Service::RewardAssignments.new(@client) - end - - def create(reward) - @client.post('/rewards', reward.to_json) - end - - def get(reward_id) - @client.get("/rewards/#{ERB::Util.url_encode(reward_id)}") - end - - def update(reward_id, reward) - @client.put("/rewards/#{ERB::Util.url_encode(reward_id)}", reward.to_json) - end - - def list(query = {}) - @client.get("/rewards", query) - end - - def delete(reward_id) - @client.delete("/rewards/#{ERB::Util.url_encode(reward_id)}") - nil - end - end - - class RewardAssignments - attr_reader :client - - def initialize(client) - @client = client - end - - def list(reward_id, query = {}) - @client.get("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments", query) - end - - def create(reward_id, assignment) - @client.post("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments", assignment.to_json) - end - - def update(reward_id, assignment_id, assignment) - @client.put("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}", assignment.to_json) - end - - def delete(reward_id, assignment_id) - @client.delete("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}") - nil - end - end - end -end diff --git a/lib/voucherify/service/segments.rb b/lib/voucherify/service/segments.rb deleted file mode 100644 index 103866a7..00000000 --- a/lib/voucherify/service/segments.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Segments - attr_reader :client - - def initialize(client) - @client = client - end - - def create(segment) - @client.post('/segments', segment.to_json) - end - - def get(id) - @client.get("/segments/#{ERB::Util.url_encode(id)}") - end - - def delete(id) - @client.delete("/segments/#{ERB::Util.url_encode(id)}") - end - end - end -end \ No newline at end of file diff --git a/lib/voucherify/service/validation_rules.rb b/lib/voucherify/service/validation_rules.rb deleted file mode 100644 index f48b94a6..00000000 --- a/lib/voucherify/service/validation_rules.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class ValidationRules - attr_reader :client - - def initialize(client) - @client = client - end - - def assignments - Voucherify::Service::ValidationRulesAssignments.new(@client) - end - - def create(validation_rules) - @client.post('/validation-rules', validation_rules.to_json) - end - - def list(query) - @client.get('/validation-rules', query) - end - - def get(id) - @client.get("/validation-rules/#{ERB::Util.url_encode(id)}") - end - - def update(validation_rules) - @client.put("/validation-rules/#{ERB::Util.url_encode(validation_rules['id'] || validation_rules[:id])}", validation_rules.to_json) - end - - def delete(id) - @client.delete("/validation-rules/#{ERB::Util.url_encode(id)}") - end - - def createAssignment(id, assignment) - @client.post("/validation-rules/#{ERB::Util.url_encode(id)}/assignments", assignment.to_json) - end - - def deleteAssignment(rule_id, assignment_id) - @client.delete("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}") - end - - def listAssignments(id, query) - @client.get("/validation-rules/#{ERB::Util.url_encode(id)}/assignments", query) - end - end - - class ValidationRulesAssignments - attr_reader :client - - def initialize(client) - @client = client - end - - def create(rule_id, assignment) - @client.post("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments", assignment.to_json) - end - - def delete(rule_id, assignment_id) - @client.delete("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}") - end - - def list(rule_id, query) - @client.get("/validation-rules/#{ERB::Util.url_encode(rule_id)}/assignments", query) - end - end - end -end diff --git a/lib/voucherify/service/validations.rb b/lib/voucherify/service/validations.rb deleted file mode 100644 index fa461d76..00000000 --- a/lib/voucherify/service/validations.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Validations - attr_reader :client - - def initialize(client) - @client = client - end - - def validate_voucher(code, context = {}) - @client.post("/vouchers/#{ERB::Util.url_encode(code)}/validate", context.to_json) - end - - def validate(code, context = {}) - if code.is_a? Hash - context = code - return @client.promotions.validate(context) - end - @client.validations.validate_voucher(code, context) - end - - end - end -end diff --git a/lib/voucherify/service/vouchers.rb b/lib/voucherify/service/vouchers.rb deleted file mode 100644 index 70a9dd3d..00000000 --- a/lib/voucherify/service/vouchers.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'uri' - -module Voucherify - module Service - class Vouchers - attr_reader :client - - def initialize(client) - @client = client - end - - def create(code, options = {}) - url = '/vouchers' - url += '/' + ERB::Util.url_encode(code) if code - @client.post(url, options.to_json) - end - - def get(code) - @client.get("/vouchers/#{ERB::Util.url_encode(code)}") - end - - def update(voucher_update) - @client.put("/vouchers/#{ERB::Util.url_encode(voucher_update['code'] || voucher_update[:code])}", voucher_update.to_json) - end - - def list(query) - @client.get('/vouchers', query) - end - - def enable(code) - @client.post("/vouchers/#{ERB::Util.url_encode(code)}/enable", nil) - nil - end - - def disable(code) - @client.post("/vouchers/#{ERB::Util.url_encode(code)}/disable", nil) - nil - end - - def delete(code, params = {}) - @client.delete("/vouchers/#{ERB::Util.url_encode(code)}", {:force => (!!(params['force'] || params[:force])).to_s}) - nil - end - - def import(vouchers) - @client.post('/vouchers/import', vouchers.to_json) - end - - def add_balance(code, balance) - @client.post("/vouchers/#{ERB::Util.url_encode(code)}/balance", balance.to_json) - end - end - end -end \ No newline at end of file diff --git a/lib/voucherify/utils.rb b/lib/voucherify/utils.rb deleted file mode 100644 index fc062498..00000000 --- a/lib/voucherify/utils.rb +++ /dev/null @@ -1,101 +0,0 @@ -module Voucherify - module Utils - def self.round_money(value) - value.round(2) - end - - def self.validate_percent_discount(discount) - if !(discount.is_a? Numeric) || !discount.between?(0, 100) - raise 'Invalid voucher, percent discount should be between 0-100.' - end - end - - def self.validate_amount_discount(discount) - if !(discount.is_a? Numeric) || discount < 0 - raise 'Invalid voucher, amount discount must be bigger than zero.' - end - end - - def self.validate_unit_discount(discount) - if !(discount.is_a? Numeric) || discount < 0 - raise 'Invalid voucher, unit discount must be bigger than zero.' - end - end - - def self.calculate_price(base_price, voucher, unit_price = nil) - e = 100.0 - - if voucher[:gift] - discount = [voucher[:gift][:balance] / e, base_price].min - return round_money(base_price - discount) - end - - if !voucher[:discount] - raise 'Unsupported voucher type.' - end - - if voucher[:discount][:type] === 'PERCENT' - discount = voucher[:discount][:percent_off] - validate_percent_discount(discount); - price_discount = base_price * (discount / 100.0) - return round_money(base_price - price_discount) - - elsif voucher[:discount][:type] === 'AMOUNT' - discount = voucher[:discount][:amount_off] / e - validate_amount_discount(discount) - new_price = base_price - discount - return round_money(new_price > 0 ? (new_price) : 0) - - elsif voucher[:discount][:type] === 'UNIT' - if !unit_price - raise 'Missing unit_price argument.' - end - discount = voucher[:discount][:unit_off] - validate_unit_discount(discount) - new_price = base_price - unit_price * discount - return round_money(new_price > 0 ? (new_price) : 0) - - else - raise 'Unsupported discount type' - end - end - - def self.calculate_discount(base_price, voucher, unit_price = nil) - e = 100.0 - - if voucher[:gift] - discount = [voucher[:gift][:balance] / e, base_price].min - return round_money(discount) - end - - if !voucher[:discount] - raise 'Unsupported voucher type.' - end - - if voucher[:discount][:type] === 'PERCENT' - discount = voucher[:discount][:percent_off] - validate_percent_discount(discount); - price_discount = base_price * (discount / 100.0) - return round_money(price_discount) - - elsif voucher[:discount][:type] === 'AMOUNT' - discount = voucher[:discount][:amount_off] / e - validate_amount_discount(discount) - new_price = base_price - discount - return round_money(new_price > 0 ? (discount) : (base_price)) - - elsif voucher[:discount][:type] === 'UNIT' - if !unit_price - raise 'Missing unit_price argument.' - end - discount = voucher[:discount][:unit_off] - validate_unit_discount(discount) - price_discount = unit_price * discount - return round_money(price_discount > base_price ? (base_price) : (price_discount)) - - else - raise 'Unsupported discount type' - end - end - end -end diff --git a/lib/voucherify/version.rb b/lib/voucherify/version.rb deleted file mode 100644 index 8f17ddd8..00000000 --- a/lib/voucherify/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Voucherify - VERSION = '4.1.0' -end diff --git a/spec/async_actions_spec.rb b/spec/async_actions_spec.rb deleted file mode 100644 index 05ffd6e3..00000000 --- a/spec/async_actions_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Async actions API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:id) { 'test-id' } - - it 'should get async action by id' do - stub_request(:get, "https://api.voucherify.io/v1/async-actions/#{id}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '{}', :headers => {}) - - voucherify.async_actions.get(id) - end - - it 'should list async actions' do - query = { - :limit => 10, - :end_date => '2021-07-16T13:58:45Z' - } - - stub_request(:get, "https://api.voucherify.io/v1/async-actions?limit=#{query[:limit]}&end_date=#{query[:end_date]}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.async_actions.list query - end - -end diff --git a/spec/campaigns_spec.rb b/spec/campaigns_spec.rb deleted file mode 100644 index 13d45959..00000000 --- a/spec/campaigns_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' -require 'rest-client' -require 'date' - -describe 'Campaigns API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let (:test_campaign_name) { 'ruby-sdk-test-campaign' } - - let (:campaign) { { - :name => test_campaign_name, - :type => 'AUTO-UPDATE', - :expiration_date => DateTime.now.next_day(10).iso8601, - :vouchers_count => 100, - :voucher => { - :type => 'DISCOUNT_VOUCHER', - :discount => { - :percent_off => '10.0', - :type => 'PERCENT' - }, - :redemption => { - :quantity => 1 - } - } - } } - - let (:voucher) { - { - :category => 'test-voucher', - :metadata => { - :locale => 'de-en' - }, - :additional_info => 'ruby-sdk-test-voucher', - :redemption => { - :quantity => 1 - } - } - } - - let (:voucher_with_code) { - { - :code => 'voucher-code', - :category => 'test-voucher', - :metadata => { - :locale => 'de-en' - }, - :additional_info => 'ruby-sdk-test-voucher', - :redemption => { - :quantity => 1 - } - } - } - - it 'should create campaign' do - stub_request(:post, 'https://api.voucherify.io/v1/campaigns') - .with(body: campaign.to_json, headers: headers) - .to_return(:status => 200, :body => campaign.to_json, :headers => {}) - - voucherify.campaigns.create(campaign) - end - - it 'should get campaign' do - stub_request(:get, "https://api.voucherify.io/v1/campaigns/#{test_campaign_name}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => campaign.to_json, :headers => {}) - - voucherify.campaigns.get(test_campaign_name) - end - - it 'should delete campaign' do - stub_request(:delete, "https://api.voucherify.io/v1/campaigns/#{test_campaign_name}?force=false") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.campaigns.delete(test_campaign_name) - end - - it 'should force delete campaign' do - stub_request(:delete, "https://api.voucherify.io/v1/campaigns/#{test_campaign_name}?force=true") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.campaigns.delete(test_campaign_name, {:force => true}) - end - - it 'should add voucher to campaign' do - stub_request(:post, "https://api.voucherify.io/v1/campaigns/#{test_campaign_name}/vouchers") - .with(body: voucher.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.campaigns.add_voucher(test_campaign_name, voucher) - end - - it 'should add voucher with specific code to campaign' do - stub_request(:post, "https://api.voucherify.io/v1/campaigns/#{test_campaign_name}/vouchers/#{voucher_with_code[:code]}") - .with(body: voucher.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.campaigns.add_voucher(test_campaign_name, voucher_with_code) - end - - it 'should import vouchers to campaign' do - stub_request(:post, "https://api.voucherify.io/v1/campaigns/#{test_campaign_name}/import") - .with(body: '[]', headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.campaigns.import_vouchers(test_campaign_name, []) - end - -end \ No newline at end of file diff --git a/spec/client_spec.rb b/spec/client_spec.rb deleted file mode 100644 index 8b4db81c..00000000 --- a/spec/client_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'Voucherify Client' do - - let(:app_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => app_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => app_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - it 'should have backend url set' do - expect(voucherify.backend_url).to eql('https://api.voucherify.io/v1') - end - - it 'should parse error' do - stub_request(:get, "https://api.voucherify.io/v1/vouchers/notFound") - .with(body: {}, headers: headers) - .to_return(:status => 404, :headers => {}, :body => { - 'code' => 404, - 'message' => 'Resource not found', - 'details' => 'Cannot find Voucher with code: notFound', - 'key' => 'resource_not_found' - }.to_json) - begin - voucherify - rescue Voucherify::VoucherifyError => e - expect(e.code).to eql(404) - expect(e.message).to eql('Resource not found') - expect(e.details).to eql('Cannot find Voucher with code: notFound') - expect(e.key).to eql('resource_not_found') - end - end -end diff --git a/spec/consents_spec.rb b/spec/consents_spec.rb deleted file mode 100644 index 185de94a..00000000 --- a/spec/consents_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' -require 'rest-client' -require 'date' - -describe 'Consents API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:consents) { { - :groups => {}, - :consents => {} - } } - - it 'should get consents' do - stub_request(:get, "https://api.voucherify.io/v1/consents") - .with(headers: headers) - .to_return(:status => 200, :body => consents.to_json, :headers => {}) - - voucherify.consents.get() - end - -end diff --git a/spec/customers_spec.rb b/spec/customers_spec.rb deleted file mode 100644 index b58ba2b7..00000000 --- a/spec/customers_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Customers API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:customer) { { - :id => 'id', - :name => 'John Doe', - :email => 'john@email.com', - :description => 'Sample description about customer', - :metadata => { - :lang => 'en' - }} } - - let(:consents) { { - :groups => {}, - :consents => {} - } } - - it 'should create customer' do - stub_request(:post, 'https://api.voucherify.io/v1/customers') - .with(body: customer.to_json, headers: headers) - .to_return(:status => 200, :body => customer.to_json, :headers => {}) - - voucherify.customers.create(customer) - end - - it 'should get customer by id' do - stub_request(:get, "https://api.voucherify.io/v1/customers/#{customer[:id]}") - .to_return(:status => 200, :body => customer.to_json, :headers => {}) - - voucherify.customers.get customer[:id] - end - - it 'should update customer' do - stub_request(:put, "https://api.voucherify.io/v1/customers/#{customer[:id]}") - .to_return(:status => 200, :body => customer.to_json, :headers => {}) - customer[:description] = 'Sample description of customer with updates' - - voucherify.customers.update customer - end - - it 'should delete customer by id' do - stub_request(:delete, "https://api.voucherify.io/v1/customers/#{customer[:id]}") - .to_return(:status => 200, :body => customer.to_json, :headers => {}) - - voucherify.customers.delete customer[:id] - end - - it 'should update customer consents' do - stub_request(:put, "https://api.voucherify.io/v1/customers/#{customer[:id]}/consents") - .to_return(:status => 200, :body => customer.to_json, :headers => {}) - - voucherify.customers.update_consents(customer[:id], consents) - end -end diff --git a/spec/distributions_spec.rb b/spec/distributions_spec.rb deleted file mode 100644 index 2dc6074f..00000000 --- a/spec/distributions_spec.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Distributions API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:payload) { { - :campaign => '300k-vouchers', - :customer => { - :source_id => 'source_id' - } - } } - - let(:publication) { { - :campaign => { - :name => '300k-vouchers', - :count => 1 - }, - :customer => { - :source_id => 'source_id' - } - } } - - let(:export) { { - :id => 'id', - :exported_object => 'voucher', - :parameters => { - :fields => ['code', 'voucher_type'], - :filters => { - :categories => { - :conditions => { - '$in' => ['postman'] - } - } - } - } - } } - - it 'should publish vouchers' do - stub_request(:post, 'https://api.voucherify.io/v1/vouchers/publish') - .with(body: payload.to_json, headers: headers) - .to_return(:status => 200, :body => payload.to_json, :headers => {}) - - voucherify.distributions.publish(payload) - end - - it 'should get export by id' do - stub_request(:get, "https://api.voucherify.io/v1/exports/#{export[:id]}") - .with(body: '', headers: headers) - .to_return(:status => 200, :body => export.to_json, :headers => {}) - - voucherify.distributions.get_export export[:id] - end - - it 'should delete export by id' do - stub_request(:delete, "https://api.voucherify.io/v1/exports/#{export[:id]}") - .with(body: '', headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.distributions.delete_export export[:id] - end - - it 'should create publication' do - stub_request(:post, 'https://api.voucherify.io/v1/publications') - .with(body: publication.to_json, headers: headers) - .to_return(:status => 200, :body => publication.to_json, :headers => {}) - - voucherify.distributions.create_publication(publication) - end - -end diff --git a/spec/events_spec.rb b/spec/events_spec.rb deleted file mode 100644 index 9624d5ed..00000000 --- a/spec/events_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Events API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:custom_event_payload) {{ - :event => 'custom_event_name', - :metadata => { - :test => true - }, - :customer => { - :id => 'cust_test_id' - }, - :referral => nil - }} - - let(:custom_event_response) {{ - :object => 'event', - :type => 'custom_event_name' - }} - - it 'should track event' do - stub_request(:post, 'https://api.voucherify.io/v1/events') - .with(body: custom_event_payload.to_json, headers: headers) - .to_return(:status => 200, :body => custom_event_response.to_json, :headers => {}) - - voucherify.events.track('custom_event_name', { :test => true }, { :id => 'cust_test_id' }) - end - - it 'should track custom event' do - stub_request(:post, 'https://api.voucherify.io/v1/events') - .with(body: custom_event_payload.to_json, headers: headers) - .to_return(:status => 200, :body => custom_event_response.to_json, :headers => {}) - - voucherify.events.track_event(custom_event_payload) - end - -end diff --git a/spec/loyalties_spec.rb b/spec/loyalties_spec.rb deleted file mode 100644 index bb8479b2..00000000 --- a/spec/loyalties_spec.rb +++ /dev/null @@ -1,305 +0,0 @@ -require 'spec_helper' -require 'rest-client' -require 'date' - -describe 'Loyalties API' do - - let(:api_url) {'https://api.voucherify.io/v1'} - - let(:application_id) {'application_id'} - let(:client_secret_key) {'client_secret_key'} - - let(:voucherify) {Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key})} - let(:headers) {{ - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - }} - - let(:customer) {{ - :id => 'some_id', - :source_id => 'some_source_id' - }} - - let(:loyalty_program) {{ - :name => 'loyalty', - :type => 'STATIC', - :voucher => { - :type => 'LOYALTY_CARD' - } - }} - - let(:reward_assignment) {{ - :reward => 'some_reward_id', - :parameters => { - :loyalty => { - :points => 15 - } - } - }} - - let(:earning_rule) {{ - :event => 'event', - :loyalty => { - :points => 10 - }, - :custom_event => { - :schema_id => 'id' - } - }} - - let(:member) {{ - :customer => customer - }} - - let(:voucher) {{ - :code => 'voucher-code', - :category => 'test-voucher', - :metadata => { - :locale => 'de-en' - }, - :additional_info => 'ruby-sdk-test-voucher', - :redemption => { - :quantity => 1 - } - }} - - let(:add_balance) {{ - :points => 20 - }} - - let(:add_balance_response) {{ - :points => 2000, - :total => 2000, - :balance =>2000, - :type => 'loyalty_card', - :object => 'balance', - :related_object => { - :type => 'voucher', - :id => 'HVqWlozp' - } - }} - - let(:redeem_reward) {{ - :reward => { - :id => 'some_reward_id' - } - }} - - let(:redeem_reward_response) {{ - :id => 'r_test_id', - :object => 'redemption', - :date => '2017-11-09T13:15:53Z', - :customer_id => customer[:id], - :tracking_id => nil, - :voucher => voucher, - :result => 'SUCCESS' - }} - - let(:loyalty_id) { 'some_id' } - let(:assignment_id) { 'some_assignment_id' } - let(:earning_rule_id) { 'some_earning_rule_id' } - let(:member_id) { 'some_member__id' } - - it 'should list loyalty programs' do - query = { - :limit => 10, - :page => 1 - } - - stub_request(:get, "#{api_url}/loyalties?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.loyalties.list(query) - end - - it 'should create loyalty program' do - stub_request(:post, "#{api_url}/loyalties") - .with(body: loyalty_program.to_json, headers: headers) - .to_return(:status => 200, :body => loyalty_program.to_json, :headers => {}) - - voucherify.loyalties.create(loyalty_program) - end - - it 'should update loyalty program' do - stub_request(:put, "#{api_url}/loyalties/#{loyalty_id}") - .with(body: loyalty_program.to_json, headers: headers) - .to_return(:status => 200, :body => loyalty_program.to_json, :headers => {}) - - voucherify.loyalties.update(loyalty_id, loyalty_program) - end - - it 'should get loyalty program' do - stub_request(:get, "#{api_url}/loyalties/#{loyalty_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => loyalty_program.to_json, :headers => {}) - - voucherify.loyalties.get(loyalty_id) - end - - it 'should delete loyalty program' do - stub_request(:delete, "#{api_url}/loyalties/#{loyalty_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => nil, :headers => {}) - - voucherify.loyalties.delete(loyalty_id) - end - - it 'should delete loyalty program with force' do - query = { - :force => true - } - - stub_request(:delete, "#{api_url}/loyalties/#{loyalty_id}?force=true") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => nil, :headers => {}) - - voucherify.loyalties.delete(loyalty_id, query) - end - - context 'reward assignments' do - - it 'should list rewards' do - query = { - :limit => 10, - :page => 1 - } - - stub_request(:get, "#{api_url}/loyalties/#{loyalty_id}/rewards?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.loyalties.reward_assignments.list(loyalty_id, query) - end - - it 'should create reward assignment' do - stub_request(:post, "#{api_url}/loyalties/#{loyalty_id}/rewards") - .with(body: [ reward_assignment ].to_json, headers: headers) - .to_return(:status => 200, :body => [ reward_assignment ].to_json, :headers => {}) - - voucherify.loyalties.reward_assignments.create(loyalty_id, reward_assignment) - end - - it 'should create multiple reward assignment' do - stub_request(:post, "#{api_url}/loyalties/#{loyalty_id}/rewards") - .with(body: [ reward_assignment ].to_json, headers: headers) - .to_return(:status => 200, :body => [ reward_assignment ].to_json, :headers => {}) - - voucherify.loyalties.reward_assignments.create(loyalty_id, [ reward_assignment ]) - end - - it 'should update reward assignment' do - stub_request(:put, "#{api_url}/loyalties/#{loyalty_id}/rewards/#{assignment_id}") - .with(body: reward_assignment.to_json, headers: headers) - .to_return(:status => 200, :body => reward_assignment.to_json, :headers => {}) - - voucherify.loyalties.reward_assignments.update(loyalty_id, assignment_id, reward_assignment) - end - - it 'should delete reward assignment' do - stub_request(:delete, "#{api_url}/loyalties/#{loyalty_id}/rewards/#{assignment_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => nil, :headers => {}) - - voucherify.loyalties.reward_assignments.delete(loyalty_id, assignment_id) - end - end - - context 'earning rules' do - - it 'should list earning rules' do - query = { - :limit => 10, - :page => 1 - } - - stub_request(:get, "#{api_url}/loyalties/#{loyalty_id}/earning-rules?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.loyalties.earning_rules.list(loyalty_id, query) - end - - it 'should create earning rule' do - stub_request(:post, "#{api_url}/loyalties/#{loyalty_id}/earning-rules") - .with(body: [ earning_rule ].to_json, headers: headers) - .to_return(:status => 200, :body => [ earning_rule ].to_json, :headers => {}) - - voucherify.loyalties.earning_rules.create(loyalty_id, earning_rule) - end - - it 'should create multiple earning rules' do - stub_request(:post, "#{api_url}/loyalties/#{loyalty_id}/earning-rules") - .with(body: [ earning_rule ].to_json, headers: headers) - .to_return(:status => 200, :body => [ earning_rule ].to_json, :headers => {}) - - voucherify.loyalties.earning_rules.create(loyalty_id, [ earning_rule ]) - end - - it 'should update earning rule' do - stub_request(:put, "#{api_url}/loyalties/#{loyalty_id}/earning-rules/#{earning_rule_id}") - .with(body: earning_rule.to_json, headers: headers) - .to_return(:status => 200, :body => earning_rule.to_json, :headers => {}) - - voucherify.loyalties.earning_rules.update(loyalty_id, earning_rule_id, earning_rule) - end - - it 'should delete earning rule' do - stub_request(:delete, "#{api_url}/loyalties/#{loyalty_id}/earning-rules/#{earning_rule_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => nil, :headers => {}) - - voucherify.loyalties.earning_rules.delete(loyalty_id, earning_rule_id) - end - end - - context 'members' do - - it 'should list members' do - query = { - :limit => 10, - :page => 1 - } - - stub_request(:get, "#{api_url}/loyalties/#{loyalty_id}/members?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.loyalties.members.list(loyalty_id, query) - end - - it 'should add member' do - stub_request(:post, "#{api_url}/loyalties/#{loyalty_id}/members") - .with(body: member.to_json, headers: headers) - .to_return(:status => 200, :body => voucher.to_json, :headers => {}) - - voucherify.loyalties.members.add(loyalty_id, member) - end - - it 'should get member' do - stub_request(:get, "#{api_url}/loyalties/#{loyalty_id}/members/#{member_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => voucher.to_json, :headers => {}) - - voucherify.loyalties.members.get(loyalty_id, member_id) - end - - it 'should add balance' do - stub_request(:post, "#{api_url}/loyalties/#{loyalty_id}/members/#{member_id}/balance") - .with(body: add_balance.to_json, headers: headers) - .to_return(:status => 200, :body => add_balance_response.to_json, :headers => {}) - - voucherify.loyalties.members.add_balance(loyalty_id, member_id, add_balance) - end - - it 'should redeem reward' do - stub_request(:post, "#{api_url}/loyalties/#{loyalty_id}/members/#{member_id}/redemption") - .with(body: redeem_reward.to_json, headers: headers) - .to_return(:status => 200, :body => redeem_reward_response.to_json, :headers => {}) - - voucherify.loyalties.members.redeem_reward(loyalty_id, member_id, redeem_reward) - end - end -end diff --git a/spec/orders_spec.rb b/spec/orders_spec.rb deleted file mode 100644 index 55d34de3..00000000 --- a/spec/orders_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'spec_helper' -require 'rest-client' -require 'date' - -describe 'Orders API' do - - let(:api_url) {'https://api.voucherify.io/v1'} - - let(:application_id) {'application_id'} - let(:client_secret_key) {'client_secret_key'} - - let(:voucherify) {Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key})} - let(:headers) {{ - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - }} - - let(:customer) {{ - :id => 'some_id', - :source_id => 'some_source_id' - }} - - let(:order) {{ - :customer => customer, - :amount => 10, - :items => [] - }} - - let(:order_id) { 'order_id' } - - it 'should create order' do - stub_request(:post, "#{api_url}/orders") - .with(body: order.to_json, headers: headers) - .to_return(:status => 200, :body => order.to_json, :headers => {}) - - voucherify.orders.create(order) - end - - it 'should get order' do - stub_request(:get, "#{api_url}/orders/#{order_id}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => order.to_json, :headers => {}) - - voucherify.orders.get(order_id) - end - - it 'should update order' do - stub_request(:put, "#{api_url}/orders/#{order_id}") - .with(body: order.to_json, headers: headers) - .to_return(:status => 200, :body => order.to_json, :headers => {}) - - voucherify.orders.update(order_id, order) - end - - it 'should list orders' do - query = { - :limit => 20, - :page => 1 - } - - stub_request(:get, "#{api_url}/orders?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.orders.list(query) - end - -end diff --git a/spec/products_spec.rb b/spec/products_spec.rb deleted file mode 100644 index b6d9a10e..00000000 --- a/spec/products_spec.rb +++ /dev/null @@ -1,117 +0,0 @@ -require 'spec_helper' -require 'rest-client' -require 'date' - -describe 'Products API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let (:product) { { - :id => 'some_id', - :name => 'name', - :source_id => 'source_id' - } } - - let (:sku) { - { - :id => 'sku_id', - :sku => 'sku', - :source_id => 'source_id' - } - } - - it 'should create product' do - stub_request(:post, 'https://api.voucherify.io/v1/products') - .with(body: product.to_json, headers: headers) - .to_return(:status => 200, :body => product.to_json, :headers => {}) - - voucherify.products.create(product) - end - - it 'should get product' do - stub_request(:get, "https://api.voucherify.io/v1/products/#{product[:id]}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => product.to_json, :headers => {}) - - voucherify.products.get(product[:id]) - end - - it 'should update product' do - stub_request(:put, "https://api.voucherify.io/v1/products/#{product[:id]}") - .with(body: product.to_json, headers: headers) - .to_return(:status => 200, :body => product.to_json, :headers => {}) - - voucherify.products.update(product) - end - - it 'should delete product' do - stub_request(:delete, "https://api.voucherify.io/v1/products/#{product[:id]}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.products.delete(product[:id]) - end - - it 'should list products' do - query = { - :limit => 10, - :page => 3 - } - - stub_request(:get, "https://api.voucherify.io/v1/products?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.products.list(query) - end - - it 'should create sku' do - stub_request(:post, "https://api.voucherify.io/v1/products/#{product[:id]}/skus") - .with(body: sku.to_json, headers: headers) - .to_return(:status => 200, :body => sku.to_json, :headers => {}) - - voucherify.products.create_sku(product[:id], sku) - end - - it 'should get sku' do - stub_request(:get, "https://api.voucherify.io/v1/products/#{product[:id]}/skus/#{sku[:id]}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => sku.to_json, :headers => {}) - - voucherify.products.get_sku(product[:id], sku[:id]) - end - - it 'should update sku' do - stub_request(:put, "https://api.voucherify.io/v1/products/#{product[:id]}/skus/#{sku[:id]}") - .with(body: sku.to_json, headers: headers) - .to_return(:status => 200, :body => sku.to_json, :headers => {}) - - voucherify.products.update_sku(product[:id], sku) - end - - it 'should delete sku' do - stub_request(:delete, "https://api.voucherify.io/v1/products/#{product[:id]}/skus/#{sku[:id]}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.products.delete_sku(product[:id], sku[:id]) - end - - it 'should list skus' do - stub_request(:get, "https://api.voucherify.io/v1/products/#{product[:id]}/skus") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.products.list_skus(product[:id]) - end - -end diff --git a/spec/promotions_spec.rb b/spec/promotions_spec.rb deleted file mode 100644 index 84bcb6f7..00000000 --- a/spec/promotions_spec.rb +++ /dev/null @@ -1,194 +0,0 @@ -require 'spec_helper' -require 'rest-client' -require 'date' - -describe 'Promotions API' do - - let(:api_url) {'https://api.voucherify.io/v1'} - - let(:application_id) {'application_id'} - let(:client_secret_key) {'client_secret_key'} - - let(:voucherify) {Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key})} - let(:headers) {{ - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - }} - - let(:promotions_tier_id) {'promo_test_id'} - let(:promotions_tier) {{ - :name => 'BMCF 2017 - $10 off for orders above $100', - :banner => 'Congratulations, you get $10 off.', - :condition => { - :orders => { - :total_amount => { - '$more_than' => [10000] - } - } - }, - :action => { - :discount => { - :type => 'AMOUNT', - :amount_off => 1000 - } - } - }} - let(:promotions_tiers) {{ - :object => 'list', - :total => 2, - :data_ref => 'tiers', - :tiers => [ - promotions_tier, - promotions_tier - ] - }} - - let(:promotion_campaign_id) {'camp_test_id'} - let(:promotion_campaign_name) {'ruby-sdk-test-promotion-campaign'} - let(:promotion_campaign) {{ - :name => promotion_campaign_name, - :campaign_type => 'PROMOTION', - :start_date => DateTime.now.iso8601, - :expiration_date => DateTime.now.next_day(10).iso8601, - :promotion => { - :tiers => [promotions_tier] - } - }} - - let(:tracking_id) {'john.doe@example.com'} - let(:customer_id) {'cust_test_id'} - let(:validation_context) {{ - :tracking_id => tracking_id, - :customer => { - :id => customer_id - }, - :order => { - :amount => 25000 - }, - :metadata => {} - }} - let(:validation_response) {{ - :tracking_id => tracking_id, - :valid => true, - :promotions => [{ - :id => promotions_tier_id, - :banner => 'You get 5% off', - :discount => { - :type => 'PERCENT', - :percent_off => 5 - }, - :discount_amount => 1250 - }], - }} - - let(:redemption_context) {{ - :customer => { - :id => customer_id - }, - :order => { - :amount => 25000 - }, - :metadata => {} - }} - let(:redemption_response) {{ - :id => 'r_test_id', - :object => 'redemption', - :date => '2017-11-09T13:15:53Z', - :customer_id => customer_id, - :tracking_id => tracking_id, - :order => { - :object => 'order', - :id => 'ord_test_id', - :source_id => nil, - :amount => 25000, - :discount_amount => 1000, - :created_at => '2017-11-09T12:15:53Z', - :updated_at => nil, - :items => nil, - :customer => { - :id => 'cust_test_id', - :object => 'customer' - }, - :referrer => nil, - :status => 'CREATED', - :metadata => nil - }, - :result => 'SUCCESS', - :promotion_tier => promotions_tier - }} - - it 'should create promotion campaign' do - stub_request(:post, "#{api_url}/campaigns") - .with(body: promotion_campaign.to_json, headers: headers) - .to_return(:status => 200, :body => promotion_campaign.to_json, :headers => {}) - - voucherify.promotions.create(promotion_campaign) - end - - it 'should validate promotion campaign' do - stub_request(:post, "#{api_url}/promotions/validation") - .with(body: validation_context.to_json, headers: headers) - .to_return(:status => 200, :body => validation_response.to_json, :headers => {}) - - voucherify.promotions.validate(validation_context) - end - - it 'should redeem promotion campaign' do - stub_request(:post, "#{api_url}/promotions/tiers/#{promotions_tier_id}/redemption") - .with(body: redemption_context.to_json, headers: headers) - .to_return(:status => 200, :body => redemption_response.to_json, :headers => {}) - - voucherify.promotions.tiers.redeem(promotions_tier_id, redemption_context) - end - - it 'should list promotion\'s tiers' do - stub_request(:get, "#{api_url}/promotions/#{ERB::Util.url_encode(promotion_campaign_id)}/tiers") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => promotions_tiers.to_json, :headers => {}) - - voucherify.promotions.tiers.list(promotion_campaign_id) - end - - it 'should create promotion\'s tier' do - stub_request(:post, "#{api_url}/promotions/#{ERB::Util.url_encode(promotion_campaign_id)}/tiers") - .with(body: promotions_tier, headers: headers) - .to_return(:status => 200, :body => promotions_tier.to_json, :headers => {}) - - voucherify.promotions.tiers.create(promotion_campaign_id, promotions_tier) - end - - it 'should update promotion\'s tier' do - promotions_tier_w_id = promotions_tier.merge({id: promotions_tier_id}) - - stub_request(:put, "#{api_url}/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}") - .with(body: promotions_tier_w_id, headers: headers) - .to_return(:status => 200, :body => promotions_tier_w_id.to_json, :headers => {}) - - voucherify.promotions.tiers.update(promotions_tier_w_id) - end - - it 'should delete promotion\'s tier' do - stub_request(:delete, "#{api_url}/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => nil, :headers => {}) - - voucherify.promotions.tiers.delete(promotions_tier_id) - end - - it 'should list tiers' do - query = { - :limit => 10, - :page => 1, - :is_available => true - } - - stub_request(:get, "#{api_url}/promotions/tiers?limit=#{query[:limit]}&page=#{query[:page]}&is_available=#{query[:is_available]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.promotions.tiers.list_tiers(query) - end - -end diff --git a/spec/redemptions_spec.rb b/spec/redemptions_spec.rb deleted file mode 100644 index d7ac654b..00000000 --- a/spec/redemptions_spec.rb +++ /dev/null @@ -1,173 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Redemptions API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:discount) { { - :code => 'discount', - :type => 'DISCOUNT_VOUCHER', - :discount => { - :type => 'PERCENT', - :percent_off => 10 - } - } } - - let(:redemption) { { - :id => 'r_XbytKOFW8wnheSScssMgRNMm' - } } - - let (:redemption_id) { 'redemption_id' } - - let(:promotions_tier_id) {'promo_test_id'} - let(:promotions_tier) {{ - :name => 'BMCF 2017 - $10 off for orders above $100', - :banner => 'Congratulations, you get $10 off.', - :condition => { - :orders => { - :total_amount => { - '$more_than' => [10000] - } - } - }, - :action => { - :discount => { - :type => 'AMOUNT', - :amount_off => 1000 - } - } - }} - let(:tracking_id) {'john.doe@example.com'} - let(:customer_id) {'cust_test_id'} - let(:promo_redemption_context) {{ - :customer => { - :id => customer_id - }, - :order => { - :amount => 25000 - }, - :metadata => {} - }} - let(:promo_redemption_response) {{ - :id => 'r_test_id', - :object => 'redemption', - :date => '2017-11-09T13:15:53Z', - :customer_id => customer_id, - :tracking_id => tracking_id, - :order => { - :object => 'order', - :id => 'ord_test_id', - :source_id => nil, - :amount => 25000, - :discount_amount => 1000, - :created_at => '2017-11-09T12:15:53Z', - :updated_at => nil, - :items => nil, - :customer => { - :id => 'cust_test_id', - :object => 'customer' - }, - :referrer => nil, - :status => 'CREATED', - :metadata => nil - }, - :result => 'SUCCESS', - :promotion_tier => promotions_tier.merge({id: promotions_tier_id}) - }} - - it 'should redeem voucher' do - stub_request(:post, "https://api.voucherify.io/v1/vouchers/#{discount[:code]}/redemption") - .with(:body => {}, headers: headers) - .to_return(:status => 200, :body => discount.to_json, :headers => {}) - - voucherify.redemptions.redeem(discount[:code]) - end - - it 'should redeem voucher with params' do - params = { - :customer => { - :source_id => 'john@email.com' - } - } - stub_request(:post, "https://api.voucherify.io/v1/vouchers/#{discount[:code]}/redemption") - .with(:body => params.to_json, headers: headers) - .to_return(:status => 200, :body => params.to_json, :headers => {}) - - voucherify.redemptions.redeem(discount[:code], params) - end - - it 'should provide a list of redemptions' do - query = { - :limit => 10, - :result => 'SUCCESS' - } - stub_request(:get, "https://api.voucherify.io/v1/redemptions?limit=#{query[:limit]}&result=#{query[:result]}") - .with(:body => {}, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.redemptions.list(query) - end - - it 'should get redemptions for voucher' do - stub_request(:get, "https://api.voucherify.io/v1/vouchers/#{discount[:code]}/redemption") - .with(:body => {}, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.redemptions.get_for_voucher discount[:code] - end - - it 'should rollback redemption' do - params = { - :customer => { - :source_id => 'john@email.com' - } - } - stub_request(:post, "https://api.voucherify.io/v1/redemptions/#{redemption_id}/rollback") - .with(:body => params.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - - voucherify.redemptions.rollback(redemption_id, params) - end - - it 'should rollback redemption with reason' do - params = { - :reason => 'mistake', - :customer => { - :source_id => 'john@email.com' - } - } - - stub_request(:post, "https://api.voucherify.io/v1/redemptions/#{redemption_id}/rollback?reason=#{params[:reason]}") - .with(:body => {:customer => {:source_id => params[:customer][:source_id]}}.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.redemptions.rollback(redemption_id, params) - end - - it 'should get redemption' do - stub_request(:get, "https://api.voucherify.io/v1/redemptions/#{redemption[:id]}") - .with(:body => '', headers: headers) - .to_return(:status => 200, :body => '{}', :headers => {}) - - voucherify.redemptions.get_redemption redemption[:id] - end - - it 'should redeem promotion campaign' do - stub_request(:post, "https://api.voucherify.io/v1/promotions/tiers/#{promotions_tier_id}/redemption") - .with(body: promo_redemption_context.to_json, headers: headers) - .to_return(:status => 200, :body => promo_redemption_response.to_json, :headers => {}) - - voucherify.redemptions.redeem(promotions_tier.merge({:id => promotions_tier_id}), promo_redemption_context) - end - -end \ No newline at end of file diff --git a/spec/rewards_spec.rb b/spec/rewards_spec.rb deleted file mode 100644 index b5393c9e..00000000 --- a/spec/rewards_spec.rb +++ /dev/null @@ -1,126 +0,0 @@ -require 'spec_helper' -require 'rest-client' -require 'date' - -describe 'Rewards API' do - - let(:api_url) {'https://api.voucherify.io/v1'} - - let(:application_id) {'application_id'} - let(:client_secret_key) {'client_secret_key'} - - let(:voucherify) {Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key})} - let(:headers) {{ - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - }} - - let(:reward) {{ - :name => 'reward', - :parameters => { - :campaign => { - :id => 'some_campaign_id' - } - } - }} - - let(:assignment) {{ - :campaign => 'some_campaign_id', - :parameters => { - :loyalty => { - :points => 10 - } - } - }} - - let(:reward_id) { 'some_reward_id'} - let(:assignment_id) { 'some_assignment_id'} - - it 'should list rewards' do - query = { - :limit => 10, - :page => 1 - } - - stub_request(:get, "#{api_url}/rewards?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.rewards.list(query) - end - - it 'should create reward' do - stub_request(:post, "#{api_url}/rewards") - .with(body: reward.to_json, headers: headers) - .to_return(:status => 200, :body => reward.to_json, :headers => {}) - - voucherify.rewards.create(reward) - end - - it 'should update reward' do - stub_request(:put, "#{api_url}/rewards/#{reward_id}") - .with(body: reward.to_json, headers: headers) - .to_return(:status => 200, :body => reward.to_json, :headers => {}) - - voucherify.rewards.update(reward_id, reward) - end - - it 'should get reward' do - stub_request(:get, "#{api_url}/rewards/#{reward_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => reward.to_json, :headers => {}) - - voucherify.rewards.get(reward_id) - end - - it 'should delete reward' do - stub_request(:delete, "#{api_url}/rewards/#{reward_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => nil, :headers => {}) - - voucherify.rewards.delete(reward_id) - end - - context 'assignments' do - - it 'should list assignments' do - query = { - :limit => 10, - :page => 1 - } - - stub_request(:get, "#{api_url}/rewards/#{reward_id}/assignments?limit=#{query[:limit]}&page=#{query[:page]}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.rewards.assignments.list(reward_id, query) - end - - it 'should create assignment' do - stub_request(:post, "#{api_url}/rewards/#{reward_id}/assignments") - .with(body: assignment.to_json, headers: headers) - .to_return(:status => 200, :body => assignment.to_json, :headers => {}) - - voucherify.rewards.assignments.create(reward_id, assignment) - end - - it 'should update assignment' do - stub_request(:put, "#{api_url}/rewards/#{reward_id}/assignments/#{assignment_id}") - .with(body: assignment.to_json, headers: headers) - .to_return(:status => 200, :body => assignment.to_json, :headers => {}) - - voucherify.rewards.assignments.update(reward_id, assignment_id, assignment) - end - - it 'should delete assignment' do - stub_request(:delete, "#{api_url}/rewards/#{reward_id}/assignments/#{assignment_id}") - .with(body: nil, headers: headers) - .to_return(:status => 200, :body => nil, :headers => {}) - - voucherify.rewards.assignments.delete(reward_id, assignment_id) - end - end - -end diff --git a/spec/segments_spec.rb b/spec/segments_spec.rb deleted file mode 100644 index 2d118590..00000000 --- a/spec/segments_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Segments API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:segment) { { - :id => 'id', - :name => 'John Doe', - :customers => ['cust_1'], - :type => 'static' - } } - - it 'should create segment' do - stub_request(:post, 'https://api.voucherify.io/v1/segments') - .with(body: segment.to_json, headers: headers) - .to_return(:status => 200, :body => segment.to_json, :headers => {}) - - voucherify.segments.create(segment) - end - - it 'should get segment by id' do - stub_request(:get, "https://api.voucherify.io/v1/segments/#{segment[:id]}") - .to_return(:status => 200, :body => '{}', :headers => {}) - - voucherify.segments.get segment[:id] - end - - it 'should delete segment by id' do - stub_request(:delete, "https://api.voucherify.io/v1/segments/#{segment[:id]}") - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.segments.delete segment[:id] - end -end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index 44988c03..00000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) -require 'voucherify' -require 'webmock/rspec' diff --git a/spec/utils_spec.rb b/spec/utils_spec.rb deleted file mode 100644 index 4fa3a67a..00000000 --- a/spec/utils_spec.rb +++ /dev/null @@ -1,137 +0,0 @@ -require 'voucherify/utils' - -describe 'Utils' do - it 'rounds money' do - amount = 1234.5678 - - rounded_money = Voucherify::Utils.round_money(amount) - - expect(rounded_money).to eq 1234.57 - end - - it 'validates percent discount' do - expect{Voucherify::Utils.validate_percent_discount(1000)}.to raise_error('Invalid voucher, percent discount should be between 0-100.') - expect{Voucherify::Utils.validate_percent_discount(-1)}.to raise_error('Invalid voucher, percent discount should be between 0-100.') - expect{Voucherify::Utils.validate_percent_discount('string')}.to raise_error('Invalid voucher, percent discount should be between 0-100.') - end - - it 'validates amount discount' do - expect{Voucherify::Utils.validate_amount_discount(-1)}.to raise_error('Invalid voucher, amount discount must be bigger than zero.') - expect{Voucherify::Utils.validate_amount_discount('string')}.to raise_error('Invalid voucher, amount discount must be bigger than zero.') - - end - - it 'validates unit discount' do - expect{Voucherify::Utils.validate_unit_discount(-1)}.to raise_error('Invalid voucher, unit discount must be bigger than zero.') - expect{Voucherify::Utils.validate_unit_discount('string')}.to raise_error('Invalid voucher, unit discount must be bigger than zero.') - - end - - it 'calculates price with percent voucher' do - percent_voucher_object = { - discount: { - percent_off: 10.0, - type: 'PERCENT' - } - } - - expect(Voucherify::Utils.calculate_price(20, percent_voucher_object)).to eq 18 - end - - it 'calculates price with amount voucher' do - amount_voucher_object = { - discount: { - amount_off: 10.0, - type: 'AMOUNT' - } - } - - expect(Voucherify::Utils.calculate_price(20, amount_voucher_object)).to eq 19.9 - end - - it 'calculates price with unit voucher' do - unit_voucher_object = { - discount: { - unit_off: 2.0, - type: 'UNIT' - } - } - - expect(Voucherify::Utils.calculate_price(20, unit_voucher_object, 8)).to eq 4 - end - - it 'calculates price with unit voucher without unit argument' do - unit_voucher_object = { - discount: { - unit_off: 2.0, - type: 'UNIT' - } - } - - expect{Voucherify::Utils.calculate_price(20, unit_voucher_object)}.to raise_error('Missing unit_price argument.') - end - - it 'calculates price with unknown voucher' do - void_voucher_object = { - discount: { - type: 'VOID' - } - } - - expect{Voucherify::Utils.calculate_price(20, void_voucher_object)}.to raise_error('Unsupported discount type') - end - - it 'calculates discount with percent voucher' do - percent_voucher_object = { - discount: { - percent_off: 10.0, - type: 'PERCENT' - } - } - - expect(Voucherify::Utils.calculate_discount(20, percent_voucher_object)).to eq 2 - end - - it 'calculates discount with amount voucher' do - amount_voucher_object = { - discount: { - amount_off: 7.0, - type: 'AMOUNT' - } - } - - expect(Voucherify::Utils.calculate_discount(20, amount_voucher_object)).to eq 0.07 - end - - it 'calculates discount with unit voucher' do - unit_voucher_object = { - discount: { - unit_off: 2.0, - type: 'UNIT' - } - } - - expect(Voucherify::Utils.calculate_discount(20, unit_voucher_object, 8)).to eq 16 - end - - it 'calculates discount with unit voucher without unit argument' do - unit_voucher_object = { - discount: { - unit_off: 2.0, - type: 'UNIT' - } - } - - expect{Voucherify::Utils.calculate_discount(20, unit_voucher_object)}.to raise_error('Missing unit_price argument.') - end - - it 'calculates discount with unknown voucher' do - void_voucher_object = { - discount: { - type: 'VOID' - } - } - - expect{Voucherify::Utils.calculate_discount(20, void_voucher_object)}.to raise_error('Unsupported discount type') - end -end diff --git a/spec/validation_rules_spec.rb b/spec/validation_rules_spec.rb deleted file mode 100644 index 3cbec475..00000000 --- a/spec/validation_rules_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Validation Rules API' do - - let(:api_url) {'https://api.voucherify.io/v1'} - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:validation_rule) { { - :id => 'id', - :voucher_code => 'test_val_rules', - :orders => { - :total_amount => { - :more_than => [10000] - } - } - } } - - let(:validation_rule_assignment) { { - :id => 'id', - :campaign => 'campaign', - :voucher => 'voucher_code', - :promotion_tier => 'promotion_tier' - } } - - it 'should create validation rule' do - stub_request(:post, "#{api_url}/validation-rules") - .with(body: validation_rule.to_json, headers: headers) - .to_return(:status => 200, :body => validation_rule.to_json, :headers => {}) - - voucherify.validation_rules.create(validation_rule) - end - - it 'should list validation rules' do - query = { - :limit => 10, - :page => 20 - } - - stub_request(:get, "#{api_url}/validation-rules?limit=#{query[:limit]}&page=#{query[:page]}") - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.validation_rules.list query - end - - it 'should get validation rule by id' do - stub_request(:get, "#{api_url}/validation-rules/#{validation_rule[:id]}") - .to_return(:status => 200, :body => validation_rule.to_json, :headers => {}) - - voucherify.validation_rules.get validation_rule[:id] - end - - it 'should update validation rule' do - stub_request(:put, "#{api_url}/validation-rules/#{validation_rule[:id]}") - .to_return(:status => 200, :body => validation_rule.to_json, :headers => {}) - validation_rule[:junction] = 'AND' - - voucherify.validation_rules.update validation_rule - end - - it 'should delete validation rule by id' do - stub_request(:delete, "#{api_url}/validation-rules/#{validation_rule[:id]}") - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.validation_rules.delete validation_rule[:id] - end - - it 'should create validation rule assignment' do - stub_request(:post, "#{api_url}/validation-rules/#{validation_rule[:id]}/assignments") - .with(body: validation_rule_assignment.to_json, headers: headers) - .to_return(:status => 200, :body => validation_rule_assignment.to_json, :headers => {}) - - voucherify.validation_rules.createAssignment(validation_rule[:id], validation_rule_assignment) - end - - it 'should delete validation rule assignment by id' do - stub_request(:delete, "#{api_url}/validation-rules/#{validation_rule[:id]}/assignments/#{validation_rule_assignment[:id]}") - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.validation_rules.deleteAssignment(validation_rule[:id], validation_rule_assignment[:id]) - end - - it 'should list validation rule assignments' do - query = { - :limit => 10, - :page => 1 - } - - stub_request(:get, "#{api_url}/validation-rules/#{validation_rule[:id]}/assignments?limit=#{query[:limit]}&page=#{query[:page]}") - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.validation_rules.listAssignments(validation_rule[:id], query) - end - - it 'should create validation rule assignment - new namespace' do - stub_request(:post, "#{api_url}/validation-rules/#{validation_rule[:id]}/assignments") - .with(body: validation_rule_assignment.to_json, headers: headers) - .to_return(:status => 200, :body => validation_rule_assignment.to_json, :headers => {}) - - voucherify.validation_rules.assignments.create(validation_rule[:id], validation_rule_assignment) - end - - it 'should delete validation rule assignment by id - new namespace' do - stub_request(:delete, "#{api_url}/validation-rules/#{validation_rule[:id]}/assignments/#{validation_rule_assignment[:id]}") - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.validation_rules.assignments.delete(validation_rule[:id], validation_rule_assignment[:id]) - end - - it 'should list validation rule assignments - new namespace' do - query = { - :limit => 10, - :page => 20 - } - - stub_request(:get, "#{api_url}/validation-rules/#{validation_rule[:id]}/assignments?limit=#{query[:limit]}&page=#{query[:page]}") - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.validation_rules.assignments.list(validation_rule[:id], query) - end -end diff --git a/spec/validations_spec.rb b/spec/validations_spec.rb deleted file mode 100644 index 711fdf2a..00000000 --- a/spec/validations_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Validations API' do - - let(:api_url) { 'https://api.voucherify.io/v1' } - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let (:voucher_code) { '91Ft4U' } - - let(:promotions_tier_id) {'promo_test_id'} - let(:tracking_id) {'john.doe@example.com'} - let(:customer_id) {'cust_test_id'} - let(:validation_context) {{ - :tracking_id => tracking_id, - :customer => { - :id => customer_id - }, - :order => { - :amount => 25000 - }, - :metadata => {} - }} - let(:validation_response) {{ - :tracking_id => tracking_id, - :valid => true, - :promotions => [{ - :id => promotions_tier_id, - :banner => 'You get 5% off', - :discount => { - :type => 'PERCENT', - :percent_off => 5 - }, - :discount_amount => 1250 - }], - }} - - it 'should validate voucher' do - context = { - tracking_id: 'john@lemon.com', - order: { - amount: 1000 - } - } - - stub_request(:post, "#{api_url}/vouchers/#{voucher_code}/validate") - .with(body: context.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.validations.validate_voucher('91Ft4U', context) - end - - it 'should validate voucher' do - context = { - tracking_id: 'john@lemon.com', - order: { - amount: 1000 - } - } - - stub_request(:post, "#{api_url}/vouchers/#{voucher_code}/validate") - .with(body: context.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.validations.validate('91Ft4U', context) - end - - it 'should validate promotion campaign' do - stub_request(:post, "#{api_url}/promotions/validation") - .with(body: validation_context.to_json, headers: headers) - .to_return(:status => 200, :body => validation_response.to_json, :headers => {}) - - voucherify.validations.validate(validation_context) - end - -end diff --git a/spec/voucherify_spec.rb b/spec/voucherify_spec.rb deleted file mode 100644 index b5297652..00000000 --- a/spec/voucherify_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'spec_helper' - -describe Voucherify do - it 'has a version number' do - expect(Voucherify::VERSION).not_to be nil - end -end diff --git a/spec/vouchers_spec.rb b/spec/vouchers_spec.rb deleted file mode 100644 index 5f1739e4..00000000 --- a/spec/vouchers_spec.rb +++ /dev/null @@ -1,162 +0,0 @@ -require 'spec_helper' -require 'rest-client' - -describe 'Vouchers API' do - - let(:application_id) { 'application_id' } - let(:client_secret_key) { 'client_secret_key' } - let(:voucherify) { Voucherify::Client.new({:applicationId => application_id, :clientSecretKey => client_secret_key}) } - let(:headers) { { - 'X-App-Id' => application_id, - 'X-App-Token' => client_secret_key, - 'X-Voucherify-Channel' => 'Ruby-SDK', - :accept => 'application/json' - } } - - let(:voucher_code) { 'ruby sdk-test-code' } - - let(:balance) { { - :amount => 2000 - } } - - it 'should create voucher with code' do - body = { - :type => 'DISCOUNT_VOUCHER', - :discount => { - :type => 'PERCENT', - :percent_off => 10 - } - } - - stub_request(:post, "https://api.voucherify.io/v1/vouchers/#{voucher_code}") - .with(body: body.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - - voucherify.vouchers.create(voucher_code, body) - end - - it 'should create voucher without specifying a code' do - body = { - :type => 'DISCOUNT_VOUCHER', - :discount => { - :type => 'PERCENT', - :percent_off => 10 - } - } - - stub_request(:post, 'https://api.voucherify.io/v1/vouchers') - .with(body: body.to_json, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.vouchers.create(nil, body) - end - - it 'should get voucher by code' do - stub_request(:get, "https://api.voucherify.io/v1/vouchers/#{voucher_code}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '{}', :headers => {}) - - voucherify.vouchers.get(voucher_code) - end - - it 'should update voucher' do - update = { - :code => voucher_code, - :type => 'DISCOUNT_VOUCHER', - :discount => { - :type => 'PERCENT', - :percent_off => 20 - } - } - - stub_request(:put, "https://api.voucherify.io/v1/vouchers/#{voucher_code}") - .with(body: update.to_json, headers: headers) - .to_return(:status => 200, :body => '{}', :headers => {}) - - voucherify.vouchers.update(update) - end - - it 'should enable voucher' do - stub_request(:post, "https://api.voucherify.io/v1/vouchers/#{voucher_code}/enable") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.vouchers.enable(voucher_code) - end - - it 'should disable voucher' do - stub_request(:post, "https://api.voucherify.io/v1/vouchers/#{voucher_code}/disable") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.vouchers.disable(voucher_code) - end - - it 'should delete voucher' do - stub_request(:delete, "https://api.voucherify.io/v1/vouchers/#{voucher_code}?force=false") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.vouchers.delete(voucher_code) - end - - it 'should force delete voucher' do - stub_request(:delete, "https://api.voucherify.io/v1/vouchers/#{voucher_code}?force=true") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '', :headers => {}) - - voucherify.vouchers.delete(voucher_code, {:force => true}) - end - - it 'should list vouchers' do - query = { - :limit => 10, - :page => 1, - :category => 'API Test' - } - - stub_request(:get, "https://api.voucherify.io/v1/vouchers?limit=#{query[:limit]}&page=#{query[:page]}&category=#{query[:category]}") - .with(body: {}, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.vouchers.list query - end - - it 'should import vouchers' do - vouchers = [ - { - :code => 'code_1', - :category => 'new_category', - :type => 'DISCOUNT_VOUCHER', - :discount => { - :amount_off => 3000, - :type => 'AMOUNT' - } - }, { - :code => 'code_2', - :category => 'new_category', - :type => 'DISCOUNT_VOUCHER', - :discount => { - :amount_off => 3000, - :type => 'AMOUNT' - } - } - ] - - stub_request(:post, 'https://api.voucherify.io/v1/vouchers/import') - .with(body: vouchers.to_json, headers: headers) - .to_return(:status => 200, :body => '[]', :headers => {}) - - voucherify.vouchers.import vouchers - end - - it 'should add gift balance' do - stub_request(:post, "https://api.voucherify.io/v1/vouchers/#{voucher_code}/balance") - .with(body: balance.to_json, headers: headers) - .to_return(:status => 200, :body => '{}', :headers => {}) - - voucherify.vouchers.add_balance(voucher_code, balance) - end - -end diff --git a/voucherify.gemspec b/voucherify.gemspec deleted file mode 100644 index 84aa92c6..00000000 --- a/voucherify.gemspec +++ /dev/null @@ -1,28 +0,0 @@ -# coding: utf-8 -lib = File.expand_path('../lib', __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'voucherify/version' - -Gem::Specification.new do |spec| - spec.name = 'voucherify' - spec.version = Voucherify::VERSION - spec.authors = ['pawelrychlik'] - spec.email = ['pawel.rychlik@rspective.pl'] - - spec.summary = %q{Ruby SDK for Voucherify. More info on http://www.voucherify.io} - spec.homepage = 'https://github.com/rspective/voucherify-ruby-sdk/' - spec.license = 'MIT' - - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - spec.bindir = 'exe' - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ['lib'] - - spec.add_development_dependency 'rake', '~> 13.0.3' - spec.add_development_dependency 'rspec', '~> 3.9.0' - spec.add_development_dependency 'webmock', '~> 3.8.2' - - spec.add_dependency 'rest-client', '~> 2.1.0' - - spec.required_ruby_version = '>= 2.2.0' -end