├── .github
└── workflows
│ ├── ISSUE_TEMPLATE
│ ├── bug_report.yml
│ ├── config.yml
│ └── feature_request.yml
│ ├── PULL_REQUEST_TEMPLATE.md
│ ├── main.yml
│ └── release.yml
├── .gitignore
├── CHANGELOG.md
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── README.md
├── README.rdoc
├── Rakefile
├── chargebee.gemspec
├── lib
├── chargebee.rb
├── chargebee
│ ├── environment.rb
│ ├── errors.rb
│ ├── list_result.rb
│ ├── models
│ │ ├── addon.rb
│ │ ├── address.rb
│ │ ├── advance_invoice_schedule.rb
│ │ ├── attached_item.rb
│ │ ├── attribute.rb
│ │ ├── billing_configuration.rb
│ │ ├── brand.rb
│ │ ├── business_entity.rb
│ │ ├── business_entity_transfer.rb
│ │ ├── card.rb
│ │ ├── comment.rb
│ │ ├── configuration.rb
│ │ ├── contact.rb
│ │ ├── contract_term.rb
│ │ ├── coupon.rb
│ │ ├── coupon_code.rb
│ │ ├── coupon_set.rb
│ │ ├── credit_note.rb
│ │ ├── credit_note_estimate.rb
│ │ ├── csv_tax_rule.rb
│ │ ├── currency.rb
│ │ ├── customer.rb
│ │ ├── customer_entitlement.rb
│ │ ├── differential_price.rb
│ │ ├── discount.rb
│ │ ├── download.rb
│ │ ├── entitlement.rb
│ │ ├── entitlement_override.rb
│ │ ├── estimate.rb
│ │ ├── event.rb
│ │ ├── export.rb
│ │ ├── feature.rb
│ │ ├── gateway_error_detail.rb
│ │ ├── gift.rb
│ │ ├── hierarchy.rb
│ │ ├── hosted_page.rb
│ │ ├── impacted_customer.rb
│ │ ├── impacted_item.rb
│ │ ├── impacted_item_price.rb
│ │ ├── impacted_subscription.rb
│ │ ├── in_app_subscription.rb
│ │ ├── invoice.rb
│ │ ├── invoice_estimate.rb
│ │ ├── item.rb
│ │ ├── item_entitlement.rb
│ │ ├── item_family.rb
│ │ ├── item_price.rb
│ │ ├── metadata.rb
│ │ ├── model.rb
│ │ ├── non_subscription.rb
│ │ ├── offer_event.rb
│ │ ├── offer_fulfillment.rb
│ │ ├── omnichannel_one_time_order.rb
│ │ ├── omnichannel_one_time_order_item.rb
│ │ ├── omnichannel_subscription.rb
│ │ ├── omnichannel_subscription_item.rb
│ │ ├── omnichannel_subscription_item_offer.rb
│ │ ├── omnichannel_subscription_item_scheduled_change.rb
│ │ ├── omnichannel_transaction.rb
│ │ ├── order.rb
│ │ ├── payment_intent.rb
│ │ ├── payment_reference_number.rb
│ │ ├── payment_schedule.rb
│ │ ├── payment_schedule_estimate.rb
│ │ ├── payment_schedule_scheme.rb
│ │ ├── payment_source.rb
│ │ ├── payment_voucher.rb
│ │ ├── personalized_offer.rb
│ │ ├── plan.rb
│ │ ├── portal_session.rb
│ │ ├── price_variant.rb
│ │ ├── pricing_page_session.rb
│ │ ├── promotional_credit.rb
│ │ ├── purchase.rb
│ │ ├── quote.rb
│ │ ├── quote_line_group.rb
│ │ ├── quoted_charge.rb
│ │ ├── quoted_ramp.rb
│ │ ├── quoted_subscription.rb
│ │ ├── ramp.rb
│ │ ├── recorded_purchase.rb
│ │ ├── resource_migration.rb
│ │ ├── rule.rb
│ │ ├── site_migration_detail.rb
│ │ ├── subscription.rb
│ │ ├── subscription_entitlement.rb
│ │ ├── subscription_entitlements_created_detail.rb
│ │ ├── subscription_entitlements_updated_detail.rb
│ │ ├── subscription_estimate.rb
│ │ ├── tax_withheld.rb
│ │ ├── third_party_payment_method.rb
│ │ ├── time_machine.rb
│ │ ├── token.rb
│ │ ├── transaction.rb
│ │ ├── unbilled_charge.rb
│ │ ├── usage.rb
│ │ ├── usage_event.rb
│ │ ├── usage_file.rb
│ │ ├── virtual_bank_account.rb
│ │ └── webhook_endpoint.rb
│ ├── nativeRequest.rb
│ ├── request.rb
│ ├── rest.rb
│ ├── result.rb
│ └── util.rb
└── ssl
│ └── ca-certs.crt
└── spec
├── chargebee
├── list_result_spec.rb
└── native_request_spec.rb
├── chargebee_spec.rb
├── errors_spec.rb
├── sample_response.rb
└── spec_helper.rb
/.github/workflows/ISSUE_TEMPLATE/bug_report.yml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: Report a bug for this repository.
3 | labels:
4 | - Bug
5 |
6 | body:
7 |
8 | - type: textarea
9 | id: what-happened
10 | attributes:
11 | label: Description of the Bug
12 | description: Please provide a clear and concise description of the bug.
13 | placeholder: Describe what you're experiencing.
14 | validations:
15 | required: true
16 |
17 | - type: textarea
18 | id: repro-steps
19 | attributes:
20 | label: Steps to reproduce
21 | description: Clear and concise instructions to reproduce the bug are essential for quick resolution.
22 | placeholder: |
23 | 1. Fetch '...'
24 | 2. Update the '....'
25 | 3. Encounter the error
26 | validations:
27 | required: true
28 |
29 | - type: textarea
30 | id: expected-behavior
31 | attributes:
32 | label: Expected Behavior
33 | description: Describe what you expected to happen.
34 | validations:
35 | required: true
36 |
37 | - type: textarea
38 | id: code-snippets
39 | attributes:
40 | label: Code Snippets (if applicable)
41 | description: If relevant, provide code snippets to clarify the issue.
42 | render: Ruby
43 | validations:
44 | required: false
45 |
46 | - type: input
47 | id: os
48 | attributes:
49 | label: Operating System
50 | placeholder: macOS
51 | validations:
52 | required: true
53 |
54 | - type: input
55 | id: language-version
56 | attributes:
57 | label: Language version
58 | placeholder: Ruby 3.2.2
59 | validations:
60 | required: true
61 |
62 | - type: input
63 | id: lib-version
64 | attributes:
65 | label: Library version
66 | placeholder: v2.32.0
67 | validations:
68 | required: true
69 |
70 | - type: textarea
71 | id: additional-context
72 | attributes:
73 | label: Additional context
74 | description: Provide any other relevant information about the problem.
75 | validations:
76 | required: false
77 |
78 | - type: markdown
79 | attributes:
80 | value: |
81 | Thank you for taking the time to submit this bug report!
82 |
--------------------------------------------------------------------------------
/.github/workflows/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Chargebee support
4 | url: https://support.chargebee.com/
5 | about: |
6 | Github issues are not an official support channel for Chargebee. If you have an urgent request we suggest you contact us through an official channel: support@chargebee.com or https://support.chargebee.com/
7 |
--------------------------------------------------------------------------------
/.github/workflows/ISSUE_TEMPLATE/feature_request.yml:
--------------------------------------------------------------------------------
1 | name: Feature Request
2 | description: Request a New Feature for the project.
3 | labels:
4 | - Feature Request
5 |
6 | body:
7 | - type: textarea
8 | id: problem
9 | attributes:
10 | label: What problem does your feature request address?
11 | description: Please provide a clear and concise description of the problem you'd like to solve. For example, "I'm frequently frustrated when..."
12 |
13 | - type: textarea
14 | id: solution
15 | attributes:
16 | label: Describe the desired solution
17 | description: Please provide a clear and concise description of the solution you would like to see implemented.
18 |
19 | - type: textarea
20 | id: alternatives
21 | attributes:
22 | label: Alternatives considered
23 | description: Describe any alternative solutions or features you may have thought about in relation to this problem.
24 |
25 | - type: textarea
26 | id: context
27 | attributes:
28 | label: Additional context
29 | description: Feel free to include any other relevant information or context regarding your feature request.
30 |
31 | - type: markdown
32 | attributes:
33 | value: |
34 | Thank you for taking the time to submit your feature request!
35 |
--------------------------------------------------------------------------------
/.github/workflows/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Description
2 |
3 | Please provide a brief overview of the changes introduced by this pull request.
4 |
5 | ### Related Issues
6 |
7 | Closes #IssueNumber
8 |
9 |
10 | ### Additional Information
11 |
12 | Include any additional information that might be helpful in reviewing the changes introduced by this pull request.
13 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: Ruby
2 |
3 | on:
4 | push: {}
5 | pull_request: {}
6 |
7 | jobs:
8 | test:
9 | runs-on: ubuntu-latest
10 | strategy:
11 | matrix:
12 | ruby-version: ['2.6', '2.7', '3.0']
13 |
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: Set up Ruby
17 | uses: ruby/setup-ruby@v1
18 | with:
19 | ruby-version: ${{ matrix.ruby-version }}
20 | bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21 |
22 | - name: Run tests
23 | run: bundle exec rspec
24 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Ruby Release
2 |
3 | on:
4 | push:
5 | tags:
6 | - "v*"
7 |
8 | jobs:
9 | release:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v5
13 |
14 | - name: Set up Ruby
15 | uses: ruby/setup-ruby@v1
16 | with:
17 | ruby-version: '3.0'
18 | bundler-cache: true
19 |
20 | - name: Verify tag matches gemspec version
21 | run: |
22 | TAG_VERSION="${GITHUB_REF#refs/tags/v}"
23 | GEMSPEC_VERSION=$(ruby -e "puts Gem::Specification.load('chargebee.gemspec').version")
24 |
25 | echo "Tag version: $TAG_VERSION"
26 | echo "Gemspec version: $GEMSPEC_VERSION"
27 |
28 | if [ "$TAG_VERSION" != "$GEMSPEC_VERSION" ]; then
29 | echo "❌ Tag version ($TAG_VERSION) does not match gemspec version ($GEMSPEC_VERSION)"
30 | exit 1
31 | fi
32 | echo "✅ Tag matches gemspec version."
33 |
34 | - name: Build gem
35 | run: gem build chargebee.gemspec
36 |
37 | - name: Push gem to RubyGems
38 | env:
39 | GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
40 | run: gem push chargebee-*.gem
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # from gitignore project
2 | *.gem
3 | *.rbc
4 | .bundle
5 | .config
6 | coverage
7 | InstalledFiles
8 | lib/bundler/man
9 | pkg
10 | rdoc
11 | spec/reports
12 | test/tmp
13 | test/version_tmp
14 | tmp
15 | .DS_Store
16 | #chargebee ignores
17 | snippets.rb
18 | .idea
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | gemspec
4 |
5 | group :development, :test do
6 | gem 'rspec', '~> 3.0.0'
7 | gem 'webmock', '~> 3.14.0'
8 | gem 'public_suffix', '< 5.0.0'
9 | end
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | PATH
2 | remote: .
3 | specs:
4 | chargebee (2.63.0)
5 | cgi (>= 0.1.0, < 1.0.0)
6 |
7 | GEM
8 | remote: https://rubygems.org/
9 | specs:
10 | addressable (2.8.7)
11 | public_suffix (>= 2.0.2, < 7.0)
12 | bigdecimal (3.2.2)
13 | cgi (0.3.2)
14 | crack (1.0.0)
15 | bigdecimal
16 | rexml
17 | diff-lcs (1.6.2)
18 | hashdiff (1.2.0)
19 | mocha (1.13.0)
20 | public_suffix (4.0.7)
21 | rexml (3.4.1)
22 | rspec (3.0.0)
23 | rspec-core (~> 3.0.0)
24 | rspec-expectations (~> 3.0.0)
25 | rspec-mocks (~> 3.0.0)
26 | rspec-core (3.0.4)
27 | rspec-support (~> 3.0.0)
28 | rspec-expectations (3.0.4)
29 | diff-lcs (>= 1.2.0, < 2.0)
30 | rspec-support (~> 3.0.0)
31 | rspec-mocks (3.0.4)
32 | rspec-support (~> 3.0.0)
33 | rspec-support (3.0.4)
34 | webmock (3.14.0)
35 | addressable (>= 2.8.0)
36 | crack (>= 0.3.2)
37 | hashdiff (>= 0.4.0, < 2.0.0)
38 |
39 | PLATFORMS
40 | arm64-darwin-21
41 | arm64-darwin-23
42 | x86_64-darwin-20
43 | x86_64-linux
44 |
45 | DEPENDENCIES
46 | chargebee!
47 | mocha
48 | public_suffix (< 5.0.0)
49 | rspec (~> 3.0.0)
50 | webmock (~> 3.14.0)
51 |
52 | BUNDLED WITH
53 | 2.3.17
54 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2011-2024 ChargeBee, Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without
8 | restriction, including without limitation the rights to use,
9 | copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the
11 | Software is furnished to do so, subject to the following
12 | conditions:
13 |
14 | The above copyright notice and this permission notice shall be
15 | included in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | OTHER DEALINGS IN THE SOFTWARE.
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Chargebee Ruby Client Library - API V2
2 |
3 | [](https://rubygems.org/gems/chargebee)
4 | [](https://rubygems.org/gems/chargebee)
5 |
6 | > [!NOTE]
7 | > [](https://discord.gg/S3SXDzXHAg)
8 | >
9 | > We are trialing a Discord server for developers building with Chargebee. Limited spots are open on a first-come basis. Join [here](https://discord.gg/S3SXDzXHAg) if interested.
10 |
11 |
12 | This is the official Ruby library for integrating with Chargebee.
13 |
14 | - 📘 For a complete reference of available APIs, check out our [API Documentation](https://apidocs.chargebee.com/docs/api/?lang=ruby).
15 | - 🧪 To explore and test API capabilities interactively, head over to our [API Explorer](https://api-explorer.chargebee.com).
16 |
17 | > Note: Chargebee now supports two API versions - [V1](https://apidocs.chargebee.com/docs/api/v1) and [V2](https://apidocs.chargebee.com/docs/api), of which V2 is the latest release and all future developments will happen in V2. This library is for API version V2. If you’re looking for V1, head to [chargebee-v1 branch](https://github.com/chargebee/chargebee-ruby/tree/chargebee-v1).
18 |
19 | ## Installation
20 |
21 | Install the latest version of the gem with the following command...
22 |
23 | $ sudo gem install chargebee -v '~>2'
24 |
25 |
26 | ## Requirements
27 |
28 | * Ruby 1.9.3 or above.
29 |
30 | ## Documentation
31 |
32 | See our [Ruby API Reference](https://apidocs.chargebee.com/docs/api?lang=ruby "API Reference").
33 |
34 | ## Usage
35 |
36 | ### To create a new subscription:
37 |
38 | ```ruby
39 | ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
40 | result = ChargeBee::Subscription.create({
41 | :id => "sub_KyVqDh__dev__NTn4VZZ1",
42 | :plan_id => "basic",
43 | })
44 | subscription = result.subscription
45 | puts "created subscription is #{subscription}"
46 | ```
47 |
48 | ### Create an Idempotent Request
49 |
50 | [Idempotency keys](https://apidocs.chargebee.com/docs/api/idempotency?prod_cat_ver=2) are passed along with request headers to allow a safe retry of POST requests.
51 |
52 | ```ruby
53 | require 'chargebee'
54 | ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
55 | result = ChargeBee::Customer.create({
56 | :first_name => "John",
57 | :last_name => "Doe",
58 | :email => "john@test.com",
59 | :locale => "fr-CA",
60 | :billing_address => {
61 | :first_name => "John",
62 | :last_name => "Doe",
63 | :line1 => "PO Box 9999",
64 | :city => "Walnut",
65 | :state => "California",
66 | :zip => "91789",
67 | :country => "US"
68 | }
69 | },
70 | nil,
71 | {"chargebee-idempotency-key" => "<>"} # Replace <> with a unique string
72 | )
73 | customer = result.customer
74 | card = result.card
75 | responseHeader = result.get_response_headers # Retrieves response headers
76 | puts(responseHeader)
77 | idempotencyReplayedValue = result.is_idempotency_replayed # Retrieves Idempotency replayed header value
78 | puts(idempotencyReplayedValue)
79 | ```
80 | `is_idempotency_replayed` method can be accessed to differentiate between original and replayed requests.
81 |
82 |
83 | ### Retry Handling
84 |
85 | Chargebee's SDK includes built-in retry logic to handle temporary network issues and server-side errors. This feature is **disabled by default** but can be **enabled when needed**.
86 |
87 | #### Key features include:
88 |
89 | - **Automatic retries for specific HTTP status codes**: Retries are automatically triggered for status codes `500`, `502`, `503`, and `504`.
90 | - **Exponential backoff**: Retry delays increase exponentially to prevent overwhelming the server.
91 | - **Rate limit management**: If a `429 Too Many Requests` response is received with a `Retry-After` header, the SDK waits for the specified duration before retrying.
92 | > *Note: Exponential backoff and max retries do not apply in this case.*
93 | - **Customizable retry behavior**: Retry logic can be configured using the `retryConfig` parameter in the environment configuration.
94 |
95 | #### Example: Customizing Retry Logic
96 |
97 | You can enable and configure the retry logic by passing a `retryConfig` object when initializing the Chargebee environment:
98 |
99 | ```ruby
100 | require 'chargebee'
101 | ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
102 |
103 | # Set comprehensive retry configuration
104 | ChargeBee::default_env.retry_config = {
105 | enabled: true,
106 | max_retries: 1,
107 | delay_ms: 2000,
108 | retry_on: [500]
109 | }
110 |
111 | # ... your Chargebee API operations ...
112 |
113 | ```
114 |
115 | #### Example: Rate Limit retry logic
116 |
117 | You can enable and configure the retry logic for rate-limit by passing a `retryConfig` object when initializing the Chargebee environment:
118 |
119 | ```ruby
120 | require 'chargebee'
121 | ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
122 |
123 | # Set comprehensive retry configuration
124 | ChargeBee::default_env.retry_config = {
125 | enabled: true,
126 | max_retries: 1,
127 | delay_ms: 1000,
128 | retry_on: [429]
129 | }
130 |
131 | # ... your Chargebee API operations ...
132 | ```
133 |
134 | ## License
135 |
136 | See the LICENSE file.
137 |
138 |
--------------------------------------------------------------------------------
/README.rdoc:
--------------------------------------------------------------------------------
1 | = Chargebee Ruby Client Library - API V2
2 |
3 | {
}[https://rubygems.org/gems/chargebee]
4 | {
}[https://rubygems.org/gems/chargebee]
5 |
6 | This is the Ruby Library for integrating with Chargebee. Sign up for a Chargebee account {here}[https://www.chargebee.com].
7 |
8 | Chargebee now supports two API versions - {V1}[https://apidocs.chargebee.com/docs/api/v1] and {V2}[https://apidocs.chargebee.com/docs/api], of which V2 is the latest release and all future developments will happen in V2. This library is for API version V2. If you’re looking for V1, head to {chargebee-v1 branch}[https://github.com/chargebee/chargebee-ruby/tree/chargebee-v1].
9 |
10 | == Installation
11 |
12 | Install the latest version of the gem with the following command...
13 |
14 | $ sudo gem install chargebee -v '~>2'
15 |
16 |
17 | == Requirements
18 |
19 | * Ruby 1.9.3 or above.
20 | * rest-client
21 |
22 | == Documentation
23 |
24 | For API reference see {here}[https://apidocs.chargebee.com/docs/api?lang=ruby]
25 |
26 | == Usage
27 |
28 | To create a new subscription:
29 |
30 | ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
31 | result = ChargeBee::Subscription.create({
32 | :id => "sub_KyVqDh__dev__NTn4VZZ1",
33 | :plan_id => "basic",
34 | })
35 | subscription = result.subscription
36 | puts "created subscription is #{subscription}"
37 |
38 | == License
39 |
40 | See the LICENSE file.
41 |
42 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 | require 'rake'
3 | require 'date'
4 |
5 | #############################################################################
6 | #
7 | # Helper functions
8 | #
9 | #############################################################################
10 |
11 | def name
12 | @name ||= Dir['*.gemspec'].first.split('.').first
13 | end
14 |
15 | def version
16 | line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17 | line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18 | end
19 |
20 | def date
21 | Date.today.to_s
22 | end
23 |
24 | def rubyforge_project
25 | name
26 | end
27 |
28 | def gemspec_file
29 | "#{name}.gemspec"
30 | end
31 |
32 | def gem_file
33 | "#{name}-#{version}.gem"
34 | end
35 |
36 | def replace_header(head, header_name)
37 | head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38 | end
39 |
40 | #############################################################################
41 | #
42 | # Standard tasks
43 | #
44 | #############################################################################
45 |
46 | task :default => :test
47 |
48 | require 'rake/testtask'
49 | Rake::TestTask.new(:test) do |test|
50 | test.libs << 'lib' << 'test'
51 | test.pattern = 'test/**/test_*.rb'
52 | test.verbose = true
53 | end
54 |
55 | desc "Generate RCov test coverage and open in your browser"
56 | task :coverage do
57 | require 'rcov'
58 | sh "rm -fr coverage"
59 | sh "rcov test/test_*.rb"
60 | sh "open coverage/index.html"
61 | end
62 |
63 | # require 'rake/rdoctask'
64 | # Rake::RDocTask.new do |rdoc|
65 | # rdoc.rdoc_dir = 'rdoc'
66 | # rdoc.title = "#{name} #{version}"
67 | # rdoc.rdoc_files.include('README*')
68 | # rdoc.rdoc_files.include('lib/**/*.rb')
69 | # end
70 |
71 | desc "Open an irb session preloaded with this library"
72 | task :console do
73 | sh "irb -rubygems -r ./lib/#{name}.rb"
74 | end
75 |
76 | #############################################################################
77 | #
78 | # Custom tasks (add your own tasks here)
79 | #
80 | #############################################################################
81 |
82 |
83 |
84 | #############################################################################
85 | #
86 | # Packaging tasks
87 | #
88 | #############################################################################
89 |
90 | desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
91 | task :release => :build do
92 | unless `git branch` =~ /^\* master$/
93 | puts "You must be on the master branch to release!"
94 | exit!
95 | end
96 | sh "git commit --allow-empty -a -m 'Release #{version}'"
97 | sh "git tag v#{version}"
98 | sh "git push origin master"
99 | sh "git push origin v#{version}"
100 | sh "gem push pkg/#{name}-#{version}.gem"
101 | end
102 |
103 | desc "Build #{gem_file} into the pkg directory"
104 | task :build => :gemspec do
105 | sh "mkdir -p pkg"
106 | sh "gem build #{gemspec_file}"
107 | sh "mv #{gem_file} pkg"
108 | end
109 |
110 | desc "Generate #{gemspec_file}"
111 | task :gemspec => :validate do
112 | # read spec file and split out manifest section
113 | spec = File.read(gemspec_file)
114 | head, manifest, tail = spec.split(" # = MANIFEST =\n")
115 |
116 | # replace name version and date
117 | replace_header(head, :name)
118 | replace_header(head, :version)
119 | replace_header(head, :date)
120 | #comment this out if your rubyforge_project has a different name
121 | replace_header(head, :rubyforge_project)
122 |
123 | # determine file list from git ls-files
124 | files = `git ls-files`.
125 | split("\n").
126 | sort.
127 | reject { |file| file =~ /^\./ }.
128 | reject { |file| file =~ /^(rdoc|pkg)/ }.
129 | map { |file| " #{file}" }.
130 | join("\n")
131 |
132 | # piece file back together and write
133 | manifest = " s.files = %w[\n#{files}\n ]\n"
134 | spec = [head, manifest, tail].join(" # = MANIFEST =\n")
135 | File.open(gemspec_file, 'w') { |io| io.write(spec) }
136 | puts "Updated #{gemspec_file}"
137 | end
138 |
139 | desc "Validate #{gemspec_file}"
140 | task :validate do
141 | libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/ssl"]
142 | unless libfiles.empty?
143 | puts "Directory `lib` should only contain a `#{name}.rb` file, `#{name}` dir and `lib/ssl` dir."
144 | exit!
145 | end
146 | unless Dir['VERSION*'].empty?
147 | puts "A `VERSION` file at root level violates Gem best practices."
148 | exit!
149 | end
150 | end
151 |
152 | desc "Create tag v#{version} and build and push #{gem_file} to Rubygems for Beta version."
153 | task :release_beta => :build do
154 | unless `git branch` =~ /^\* next$/
155 | puts "You must be on the next branch to release beta!"
156 | exit!
157 | end
158 | sh "git commit --allow-empty -a -m 'Release #{version}'"
159 | sh "git tag v#{version}"
160 | sh "git push origin next"
161 | sh "git push origin v#{version}"
162 | sh "gem push pkg/#{name}-#{version}.gem"
163 | end
164 |
--------------------------------------------------------------------------------
/chargebee.gemspec:
--------------------------------------------------------------------------------
1 | Gem::Specification.new do |s|
2 | s.specification_version = 2 if s.respond_to? :specification_version=
3 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4 | s.rubygems_version = '1.3.5'
5 | s.required_ruby_version = '>= 1.9.3'
6 | s.name = 'chargebee'
7 | s.version = '2.63.0'
8 | s.date = '2025-10-28'
9 | s.summary = "Ruby client for Chargebee API."
10 | s.description = "Subscription Billing - Simple. Secure. Affordable. More details at www.chargebee.com."
11 | s.metadata = {
12 | "changelog_uri" => "https://github.com/chargebee/chargebee-ruby/blob/master/CHANGELOG.md"
13 | }
14 |
15 | s.authors = ['Rajaraman S', 'Thiyagarajan T']
16 | s.email = ['rr@chargebee.com', 'thiyagu@chargebee.com']
17 | s.homepage = 'https://apidocs.chargebee.com/docs/api?lang=ruby'
18 | s.license = 'MIT'
19 |
20 | s.require_paths = %w[lib]
21 |
22 | s.rdoc_options = ["--charset=UTF-8"]
23 | s.extra_rdoc_files = %w[README.md LICENSE]
24 |
25 | s.add_dependency('cgi', '>=0.1.0', '<1.0.0')
26 | s.add_development_dependency('rspec', '~> 3.0.0')
27 | s.add_development_dependency('mocha')
28 |
29 | # = MANIFEST =
30 | s.files = %w[
31 | CHANGELOG.md
32 | Gemfile
33 | Gemfile.lock
34 | LICENSE
35 | README.md
36 | README.rdoc
37 | Rakefile
38 | chargebee.gemspec
39 | lib/chargebee.rb
40 | lib/chargebee/environment.rb
41 | lib/chargebee/errors.rb
42 | lib/chargebee/list_result.rb
43 | lib/chargebee/models/addon.rb
44 | lib/chargebee/models/address.rb
45 | lib/chargebee/models/advance_invoice_schedule.rb
46 | lib/chargebee/models/attached_item.rb
47 | lib/chargebee/models/attribute.rb
48 | lib/chargebee/models/billing_configuration.rb
49 | lib/chargebee/models/brand.rb
50 | lib/chargebee/models/business_entity.rb
51 | lib/chargebee/models/business_entity_transfer.rb
52 | lib/chargebee/models/card.rb
53 | lib/chargebee/models/comment.rb
54 | lib/chargebee/models/configuration.rb
55 | lib/chargebee/models/contact.rb
56 | lib/chargebee/models/contract_term.rb
57 | lib/chargebee/models/coupon.rb
58 | lib/chargebee/models/coupon_code.rb
59 | lib/chargebee/models/coupon_set.rb
60 | lib/chargebee/models/credit_note.rb
61 | lib/chargebee/models/credit_note_estimate.rb
62 | lib/chargebee/models/csv_tax_rule.rb
63 | lib/chargebee/models/currency.rb
64 | lib/chargebee/models/customer.rb
65 | lib/chargebee/models/customer_entitlement.rb
66 | lib/chargebee/models/differential_price.rb
67 | lib/chargebee/models/discount.rb
68 | lib/chargebee/models/download.rb
69 | lib/chargebee/models/entitlement.rb
70 | lib/chargebee/models/entitlement_override.rb
71 | lib/chargebee/models/estimate.rb
72 | lib/chargebee/models/event.rb
73 | lib/chargebee/models/export.rb
74 | lib/chargebee/models/feature.rb
75 | lib/chargebee/models/gateway_error_detail.rb
76 | lib/chargebee/models/gift.rb
77 | lib/chargebee/models/hierarchy.rb
78 | lib/chargebee/models/hosted_page.rb
79 | lib/chargebee/models/impacted_customer.rb
80 | lib/chargebee/models/impacted_item.rb
81 | lib/chargebee/models/impacted_item_price.rb
82 | lib/chargebee/models/impacted_subscription.rb
83 | lib/chargebee/models/in_app_subscription.rb
84 | lib/chargebee/models/invoice.rb
85 | lib/chargebee/models/invoice_estimate.rb
86 | lib/chargebee/models/item.rb
87 | lib/chargebee/models/item_entitlement.rb
88 | lib/chargebee/models/item_family.rb
89 | lib/chargebee/models/item_price.rb
90 | lib/chargebee/models/metadata.rb
91 | lib/chargebee/models/model.rb
92 | lib/chargebee/models/non_subscription.rb
93 | lib/chargebee/models/offer_event.rb
94 | lib/chargebee/models/offer_fulfillment.rb
95 | lib/chargebee/models/omnichannel_one_time_order.rb
96 | lib/chargebee/models/omnichannel_one_time_order_item.rb
97 | lib/chargebee/models/omnichannel_subscription.rb
98 | lib/chargebee/models/omnichannel_subscription_item.rb
99 | lib/chargebee/models/omnichannel_subscription_item_offer.rb
100 | lib/chargebee/models/omnichannel_subscription_item_scheduled_change.rb
101 | lib/chargebee/models/omnichannel_transaction.rb
102 | lib/chargebee/models/order.rb
103 | lib/chargebee/models/payment_intent.rb
104 | lib/chargebee/models/payment_reference_number.rb
105 | lib/chargebee/models/payment_schedule.rb
106 | lib/chargebee/models/payment_schedule_estimate.rb
107 | lib/chargebee/models/payment_schedule_scheme.rb
108 | lib/chargebee/models/payment_source.rb
109 | lib/chargebee/models/payment_voucher.rb
110 | lib/chargebee/models/personalized_offer.rb
111 | lib/chargebee/models/plan.rb
112 | lib/chargebee/models/portal_session.rb
113 | lib/chargebee/models/price_variant.rb
114 | lib/chargebee/models/pricing_page_session.rb
115 | lib/chargebee/models/promotional_credit.rb
116 | lib/chargebee/models/purchase.rb
117 | lib/chargebee/models/quote.rb
118 | lib/chargebee/models/quote_line_group.rb
119 | lib/chargebee/models/quoted_charge.rb
120 | lib/chargebee/models/quoted_ramp.rb
121 | lib/chargebee/models/quoted_subscription.rb
122 | lib/chargebee/models/ramp.rb
123 | lib/chargebee/models/recorded_purchase.rb
124 | lib/chargebee/models/resource_migration.rb
125 | lib/chargebee/models/rule.rb
126 | lib/chargebee/models/site_migration_detail.rb
127 | lib/chargebee/models/subscription.rb
128 | lib/chargebee/models/subscription_entitlement.rb
129 | lib/chargebee/models/subscription_entitlements_created_detail.rb
130 | lib/chargebee/models/subscription_entitlements_updated_detail.rb
131 | lib/chargebee/models/subscription_estimate.rb
132 | lib/chargebee/models/tax_withheld.rb
133 | lib/chargebee/models/third_party_payment_method.rb
134 | lib/chargebee/models/time_machine.rb
135 | lib/chargebee/models/token.rb
136 | lib/chargebee/models/transaction.rb
137 | lib/chargebee/models/unbilled_charge.rb
138 | lib/chargebee/models/usage.rb
139 | lib/chargebee/models/usage_event.rb
140 | lib/chargebee/models/usage_file.rb
141 | lib/chargebee/models/virtual_bank_account.rb
142 | lib/chargebee/models/webhook_endpoint.rb
143 | lib/chargebee/nativeRequest.rb
144 | lib/chargebee/request.rb
145 | lib/chargebee/rest.rb
146 | lib/chargebee/result.rb
147 | lib/chargebee/util.rb
148 | lib/ssl/ca-certs.crt
149 | spec/chargebee/list_result_spec.rb
150 | spec/chargebee/native_request_spec.rb
151 | spec/chargebee_spec.rb
152 | spec/errors_spec.rb
153 | spec/sample_response.rb
154 | spec/spec_helper.rb
155 | ]
156 | # = MANIFEST =
157 |
158 | s.test_files = s.files.select { |path| path =~ /^spec\/.*\.rb/ }
159 | end
160 |
--------------------------------------------------------------------------------
/lib/chargebee.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/chargebee/environment'
2 | require File.dirname(__FILE__) + '/chargebee/nativeRequest'
3 | require File.dirname(__FILE__) + '/chargebee/util'
4 | require File.dirname(__FILE__) + '/chargebee/request'
5 | require File.dirname(__FILE__) + '/chargebee/result'
6 | require File.dirname(__FILE__) + '/chargebee/list_result'
7 |
8 | require File.dirname(__FILE__) + '/chargebee/errors'
9 |
10 | require File.dirname(__FILE__) + '/chargebee/models/model'
11 | require File.dirname(__FILE__) + '/chargebee/models/subscription'
12 | require File.dirname(__FILE__) + '/chargebee/models/customer'
13 | require File.dirname(__FILE__) + '/chargebee/models/card'
14 | require File.dirname(__FILE__) + '/chargebee/models/third_party_payment_method'
15 | require File.dirname(__FILE__) + '/chargebee/models/address'
16 | require File.dirname(__FILE__) + '/chargebee/models/transaction'
17 | require File.dirname(__FILE__) + '/chargebee/models/invoice'
18 | require File.dirname(__FILE__) + '/chargebee/models/order'
19 | require File.dirname(__FILE__) + '/chargebee/models/credit_note'
20 | require File.dirname(__FILE__) + '/chargebee/models/estimate'
21 | require File.dirname(__FILE__) + '/chargebee/models/subscription_estimate'
22 | require File.dirname(__FILE__) + '/chargebee/models/invoice_estimate'
23 | require File.dirname(__FILE__) + '/chargebee/models/credit_note_estimate'
24 | require File.dirname(__FILE__) + '/chargebee/models/hosted_page'
25 | require File.dirname(__FILE__) + '/chargebee/models/event'
26 | require File.dirname(__FILE__) + '/chargebee/models/plan'
27 | require File.dirname(__FILE__) + '/chargebee/models/addon'
28 | require File.dirname(__FILE__) + '/chargebee/models/coupon'
29 | require File.dirname(__FILE__) + '/chargebee/models/coupon_code'
30 | require File.dirname(__FILE__) + '/chargebee/models/coupon_set'
31 | require File.dirname(__FILE__) + '/chargebee/models/comment'
32 | require File.dirname(__FILE__) + '/chargebee/models/portal_session'
33 | require File.dirname(__FILE__) + '/chargebee/models/download'
34 | require File.dirname(__FILE__) + '/chargebee/models/entitlement'
35 | require File.dirname(__FILE__) + '/chargebee/models/site_migration_detail'
36 | require File.dirname(__FILE__) + '/chargebee/models/resource_migration'
37 | require File.dirname(__FILE__) + '/chargebee/models/payment_source'
38 | require File.dirname(__FILE__) + '/chargebee/models/unbilled_charge'
39 | require File.dirname(__FILE__) + '/chargebee/models/time_machine'
40 | require File.dirname(__FILE__) + '/chargebee/models/promotional_credit.rb'
41 | require File.dirname(__FILE__) + '/chargebee/models/virtual_bank_account.rb'
42 | require File.dirname(__FILE__) + '/chargebee/models/export'
43 | require File.dirname(__FILE__) + '/chargebee/models/gift'
44 | require File.dirname(__FILE__) + '/chargebee/models/quote'
45 | require File.dirname(__FILE__) + '/chargebee/models/contact.rb'
46 | require File.dirname(__FILE__) + '/chargebee/models/hierarchy.rb'
47 | require File.dirname(__FILE__) + '/chargebee/models/payment_intent.rb'
48 | require File.dirname(__FILE__) + '/chargebee/models/attached_item.rb'
49 | require File.dirname(__FILE__) + '/chargebee/models/differential_price.rb'
50 | require File.dirname(__FILE__) + '/chargebee/models/item.rb'
51 | require File.dirname(__FILE__) + '/chargebee/models/item_family.rb'
52 | require File.dirname(__FILE__) + '/chargebee/models/item_price.rb'
53 | require File.dirname(__FILE__) + '/chargebee/models/usage.rb'
54 | require File.dirname(__FILE__) + '/chargebee/models/advance_invoice_schedule'
55 | require File.dirname(__FILE__) + '/chargebee/models/contract_term.rb'
56 | require File.dirname(__FILE__) + '/chargebee/models/entitlement_override.rb'
57 | require File.dirname(__FILE__) + '/chargebee/models/feature.rb'
58 | require File.dirname(__FILE__) + '/chargebee/models/impacted_item.rb'
59 | require File.dirname(__FILE__) + '/chargebee/models/impacted_subscription.rb'
60 | require File.dirname(__FILE__) + '/chargebee/models/in_app_subscription.rb'
61 | require File.dirname(__FILE__) + '/chargebee/models/item_entitlement.rb'
62 | require File.dirname(__FILE__) + '/chargebee/models/purchase.rb'
63 | require File.dirname(__FILE__) + '/chargebee/models/quote_line_group.rb'
64 | require File.dirname(__FILE__) + '/chargebee/models/quoted_charge.rb'
65 | require File.dirname(__FILE__) + '/chargebee/models/quoted_subscription.rb'
66 | require File.dirname(__FILE__) + '/chargebee/models/subscription_entitlement'
67 | require File.dirname(__FILE__) + '/chargebee/models/tax_withheld.rb'
68 | require File.dirname(__FILE__) + '/chargebee/models/token.rb'
69 | require File.dirname(__FILE__) + '/chargebee/models/non_subscription.rb'
70 | require File.dirname(__FILE__) + '/chargebee/models/price_variant'
71 | require File.dirname(__FILE__) + '/chargebee/models/ramp'
72 | require File.dirname(__FILE__) + '/chargebee/models/business_entity'
73 | require File.dirname(__FILE__) + '/chargebee/models/business_entity_transfer'
74 | require File.dirname(__FILE__) + '/chargebee/models/currency'
75 | require File.dirname(__FILE__) + '/chargebee/models/pricing_page_session'
76 | require File.dirname(__FILE__) + '/chargebee/models/metadata'
77 | require File.dirname(__FILE__) + '/chargebee/models/customer_entitlement'
78 | require File.dirname(__FILE__) + '/chargebee/models/payment_schedule'
79 | require File.dirname(__FILE__) + '/chargebee/models/payment_schedule_scheme'
80 | require File.dirname(__FILE__) + '/chargebee/models/payment_schedule_estimate'
81 | require File.dirname(__FILE__) + '/chargebee/models/omnichannel_subscription'
82 | require File.dirname(__FILE__) + '/chargebee/models/omnichannel_transaction'
83 | require File.dirname(__FILE__) + '/chargebee/models/recorded_purchase'
84 | require File.dirname(__FILE__) + '/chargebee/models/omnichannel_subscription_item'
85 | require File.dirname(__FILE__) + '/chargebee/models/configuration'
86 | require File.dirname(__FILE__) + '/chargebee/models/usage_event'
87 | require File.dirname(__FILE__) + '/chargebee/models/rule'
88 | require File.dirname(__FILE__) + '/chargebee/models/omnichannel_subscription_item_scheduled_change'
89 | require File.dirname(__FILE__) + '/chargebee/models/usage_file'
90 | require File.dirname(__FILE__) + '/chargebee/models/quoted_ramp'
91 | require File.dirname(__FILE__) + '/chargebee/models/webhook_endpoint'
92 | require File.dirname(__FILE__) + '/chargebee/models/omnichannel_one_time_order'
93 | require File.dirname(__FILE__) + '/chargebee/models/omnichannel_one_time_order_item'
94 | require File.dirname(__FILE__) + '/chargebee/models/personalized_offer'
95 | require File.dirname(__FILE__) + '/chargebee/models/offer_event'
96 | require File.dirname(__FILE__) + '/chargebee/models/offer_fulfillment'
97 |
98 |
99 | module ChargeBee
100 |
101 | VERSION = '2.63.0'
102 |
103 | @@default_env = nil
104 | @@verify_ca_certs = true
105 | @@ca_cert_path = File.join(File.dirname(__FILE__), '/ssl/ca-certs.crt')
106 | @@user_agent = "Chargebee-Ruby-Client v#{self::VERSION}"
107 |
108 | def self.configure(options)
109 | @@default_env = Environment.new(options)
110 | end
111 |
112 | def self.default_env
113 | @@default_env
114 | end
115 |
116 | def self.verify_ca_certs=(verify)
117 | @@verify_ca_certs = verify
118 | end
119 |
120 | def self.verify_ca_certs?
121 | @@verify_ca_certs
122 | end
123 |
124 | def self.ca_cert_path
125 | @@ca_cert_path
126 | end
127 |
128 | def self.source(source)
129 | @@user_agent = @@user_agent + ' ' + source unless source.nil?
130 | end
131 |
132 | def self.user_agent
133 | @@user_agent
134 | end
135 |
136 | def self.update_connect_timeout_secs(connect_timeout)
137 | @@default_env.connect_timeout = connect_timeout
138 | end
139 |
140 | def self.update_read_timeout_secs(read_timeout)
141 | @@default_env.read_timeout = read_timeout
142 | end
143 | end
144 |
--------------------------------------------------------------------------------
/lib/chargebee/environment.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Environment
3 | API_VERSION = "v2"
4 | # in seconds
5 | TIME_MACHINE_TIMEOUT = 3
6 | EXPORT_TIMEOUT = 10
7 | CONNECT_TIMEOUT = 30
8 | READ_TIMEOUT = 80
9 |
10 | attr_accessor :api_key, :site, :time_machine_sleeptime, :export_sleeptime, :connect_timeout, :read_timeout
11 | attr_reader :api_endpoint
12 |
13 | # Add retry_config and enable_debug_logs
14 | attr_accessor :retry_config, :enable_debug_logs
15 |
16 | def initialize(options)
17 | options[:time_machine_sleeptime] ||= TIME_MACHINE_TIMEOUT
18 | options[:export_sleeptime] ||= EXPORT_TIMEOUT
19 | options[:connect_timeout] ||= CONNECT_TIMEOUT
20 | options[:read_timeout] ||= READ_TIMEOUT
21 | [:api_key, :site, :time_machine_sleeptime, :export_sleeptime, :connect_timeout, :read_timeout].each do |attr|
22 | instance_variable_set "@#{attr}", options[attr]
23 | end
24 | @retry_config = options[:retry_config]
25 | @enable_debug_logs = options[:enable_debug_logs] || false
26 | if($CHARGEBEE_DOMAIN == nil)
27 | @api_endpoint = "https://#{@site}.chargebee.com/api/#{API_VERSION}"
28 | else
29 | @api_endpoint = "#{$ENV_PROTOCOL == nil ? "http": "https"}://#{@site}.#{$CHARGEBEE_DOMAIN}/api/#{API_VERSION}"
30 | end
31 | end
32 |
33 | def api_url(url, sub_domain = nil)
34 | protocol = $ENV_PROTOCOL || "https"
35 | domain = $CHARGEBEE_DOMAIN || "chargebee.com"
36 |
37 | if sub_domain
38 | @api_endpoint = "#{protocol}://#{@site}.#{sub_domain}.#{domain}/api/#{API_VERSION}"
39 | else
40 | @api_endpoint = "#{protocol}://#{@site}.#{domain}/api/#{API_VERSION}"
41 | end
42 | @api_endpoint + url
43 | end
44 | end
45 | end
--------------------------------------------------------------------------------
/lib/chargebee/errors.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Error < StandardError
3 | attr_reader :original_error
4 |
5 | def initialize(message=nil,original_error = nil)
6 | super message
7 | @original_error = original_error
8 | end
9 | end
10 |
11 | class IOError < Error; end
12 |
13 | class APIError < Error
14 |
15 | attr_reader :http_status_code, :type, :api_error_code, :param, :json_obj, :error_cause_id,
16 | #Deprecated attributes
17 | :http_code, :http_body, :error_code
18 |
19 | def initialize(http_code=nil, json_obj = nil)
20 | super json_obj[:message]
21 | @json_obj = json_obj
22 | @http_status_code = http_code
23 | @type = json_obj[:type]
24 | @api_error_code = json_obj[:api_error_code]
25 | @param = json_obj[:param]
26 | @error_cause_id = json_obj[:error_cause_id]
27 |
28 | #Deprecated attributes
29 | @error_code = json_obj[:error_code]
30 | @http_code = http_code
31 | @http_body = json_obj.to_s
32 | end
33 |
34 | end
35 |
36 |
37 | class OperationFailedError < APIError; end
38 |
39 | class InvalidRequestError < APIError; end
40 |
41 | class PaymentError < APIError; end
42 |
43 | class UbbBatchIngestionInvalidRequestError < APIError
44 | attr_reader :batch_id, :failed_events
45 | def initialize(http_code=nil, json_obj=nil)
46 | super(http_code, json_obj)
47 | @batch_id=json_obj[:batch_id]
48 | @failed_events=json_obj[:failed_events]
49 | end
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/lib/chargebee/list_result.rb:
--------------------------------------------------------------------------------
1 | require 'forwardable'
2 |
3 | module ChargeBee
4 | class ListResult
5 | extend Forwardable
6 | include Enumerable
7 |
8 | def_delegator :@list, :each, :each
9 | def_delegator :@list, :length, :length
10 |
11 | attr_reader :next_offset
12 |
13 | def initialize(response, next_offset=nil, rheaders = nil, http_status_code=nil)
14 | @response = response
15 | @rheaders = rheaders
16 | @http_status_code = http_status_code
17 | @list = Array.new
18 | if next_offset
19 | begin
20 | @next_offset = JSON.parse(next_offset).to_s
21 | rescue JSON::ParserError
22 | @next_offset = next_offset.to_s
23 | end
24 | end
25 | initItems()
26 | end
27 |
28 | def get_response_headers()
29 | @rheaders
30 | end
31 |
32 | def get_raw_response()
33 | @response
34 | end
35 | def get_http_status_code()
36 | @http_status_code
37 | end
38 |
39 | private
40 | def initItems()
41 | @response.each do |item|
42 | @list.push(Result.new(item))
43 | end
44 | end
45 |
46 | end
47 | end
48 |
--------------------------------------------------------------------------------
/lib/chargebee/models/addon.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Addon < Model
3 |
4 | class Tier < Model
5 | attr_accessor :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :pricing_type, :package_size
6 | end
7 |
8 | class TaxProvidersField < Model
9 | attr_accessor :provider_name, :field_id, :field_value
10 | end
11 |
12 | attr_accessor :id, :name, :invoice_name, :description, :pricing_model, :type, :charge_type,
13 | :price, :currency_code, :period, :period_unit, :unit, :status, :archived_at, :enabled_in_portal,
14 | :tax_code, :hsn_code, :taxjar_product_code, :avalara_sale_type, :avalara_transaction_type, :avalara_service_type,
15 | :sku, :accounting_code, :accounting_category1, :accounting_category2, :accounting_category3,
16 | :accounting_category4, :is_shippable, :shipping_frequency_period, :shipping_frequency_period_unit,
17 | :resource_version, :updated_at, :price_in_decimal, :included_in_mrr, :channel, :proration_type,
18 | :invoice_notes, :taxable, :tax_profile_id, :meta_data, :tiers, :tax_providers_fields, :show_description_in_invoices,
19 | :show_description_in_quotes
20 |
21 | # OPERATIONS
22 | #-----------
23 |
24 | def self.create(params, env=nil, headers={})
25 | jsonKeys = {
26 | :meta_data => 0,
27 | }
28 | options = {
29 | :isIdempotent => true
30 | }
31 | Request.send('post', uri_path("addons"), params, env, headers,nil, false, jsonKeys, options)
32 | end
33 |
34 | def self.update(id, params, env=nil, headers={})
35 | jsonKeys = {
36 | :meta_data => 0,
37 | }
38 | options = {
39 | :isIdempotent => true
40 | }
41 | Request.send('post', uri_path("addons",id.to_s), params, env, headers,nil, false, jsonKeys, options)
42 | end
43 |
44 | def self.list(params={}, env=nil, headers={})
45 | jsonKeys = {
46 | }
47 | options = {}
48 | Request.send_list_request('get', uri_path("addons"), params, env, headers,nil, false, jsonKeys, options)
49 | end
50 |
51 | def self.retrieve(id, env=nil, headers={})
52 | jsonKeys = {
53 | }
54 | options = {}
55 | Request.send('get', uri_path("addons",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
56 | end
57 |
58 | def self.delete(id, env=nil, headers={})
59 | jsonKeys = {
60 | }
61 | options = {
62 | :isIdempotent => true
63 | }
64 | Request.send('post', uri_path("addons",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
65 | end
66 |
67 | def self.copy(params, env=nil, headers={})
68 | jsonKeys = {
69 | }
70 | options = {
71 | :isIdempotent => true
72 | }
73 | Request.send('post', uri_path("addons","copy"), params, env, headers,nil, false, jsonKeys, options)
74 | end
75 |
76 | def self.unarchive(id, env=nil, headers={})
77 | jsonKeys = {
78 | }
79 | options = {
80 | :isIdempotent => true
81 | }
82 | Request.send('post', uri_path("addons",id.to_s,"unarchive"), {}, env, headers,nil, false, jsonKeys, options)
83 | end
84 |
85 | end # ~Addon
86 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/address.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Address < Model
3 |
4 | attr_accessor :label, :first_name, :last_name, :email, :company, :phone, :addr, :extended_addr,
5 | :extended_addr2, :city, :state_code, :state, :country, :zip, :validation_status, :subscription_id
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.retrieve(params, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {}
14 | Request.send('get', uri_path("addresses"), params, env, headers,nil, false, jsonKeys, options)
15 | end
16 |
17 | def self.update(params, env=nil, headers={})
18 | jsonKeys = {
19 | }
20 | options = {
21 | :isIdempotent => true
22 | }
23 | Request.send('post', uri_path("addresses"), params, env, headers,nil, false, jsonKeys, options)
24 | end
25 |
26 | end # ~Address
27 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/advance_invoice_schedule.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class AdvanceInvoiceSchedule < Model
3 |
4 | class FixedIntervalSchedule < Model
5 | attr_accessor :end_schedule_on, :number_of_occurrences, :days_before_renewal, :end_date, :created_at, :terms_to_charge
6 | end
7 |
8 | class SpecificDatesSchedule < Model
9 | attr_accessor :terms_to_charge, :date, :created_at
10 | end
11 |
12 | attr_accessor :id, :schedule_type, :fixed_interval_schedule, :specific_dates_schedule
13 |
14 | # OPERATIONS
15 | #-----------
16 |
17 | end # ~AdvanceInvoiceSchedule
18 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/attached_item.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class AttachedItem < Model
3 |
4 | attr_accessor :id, :parent_item_id, :item_id, :type, :status, :quantity, :quantity_in_decimal,
5 | :billing_cycles, :charge_on_event, :charge_once, :created_at, :resource_version, :updated_at,
6 | :channel, :business_entity_id, :deleted
7 |
8 | # OPERATIONS
9 | #-----------
10 |
11 | def self.create(id, params, env=nil, headers={})
12 | jsonKeys = {
13 | }
14 | options = {
15 | :isIdempotent => true
16 | }
17 | Request.send('post', uri_path("items",id.to_s,"attached_items"), params, env, headers,nil, false, jsonKeys, options)
18 | end
19 |
20 | def self.update(id, params, env=nil, headers={})
21 | jsonKeys = {
22 | }
23 | options = {
24 | :isIdempotent => true
25 | }
26 | Request.send('post', uri_path("attached_items",id.to_s), params, env, headers,nil, false, jsonKeys, options)
27 | end
28 |
29 | def self.retrieve(id, params, env=nil, headers={})
30 | jsonKeys = {
31 | }
32 | options = {}
33 | Request.send('get', uri_path("attached_items",id.to_s), params, env, headers,nil, false, jsonKeys, options)
34 | end
35 |
36 | def self.delete(id, params, env=nil, headers={})
37 | jsonKeys = {
38 | }
39 | options = {
40 | :isIdempotent => true
41 | }
42 | Request.send('post', uri_path("attached_items",id.to_s,"delete"), params, env, headers,nil, false, jsonKeys, options)
43 | end
44 |
45 | def self.list(id, params={}, env=nil, headers={})
46 | jsonKeys = {
47 | }
48 | options = {}
49 | Request.send_list_request('get', uri_path("items",id.to_s,"attached_items"), params, env, headers,nil, false, jsonKeys, options)
50 | end
51 |
52 | end # ~AttachedItem
53 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/attribute.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Attribute < Model
3 |
4 | attr_accessor :name, :value
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~Attribute
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/billing_configuration.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class BillingConfiguration < Model
3 |
4 | class BillingDate < Model
5 | attr_accessor :start_date, :end_date
6 | end
7 |
8 | attr_accessor :is_calendar_billing_enabled, :billing_dates
9 |
10 | # OPERATIONS
11 | #-----------
12 |
13 | end # ~BillingConfiguration
14 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/brand.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Brand < Model
3 |
4 | attr_accessor :id, :name
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~Brand
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/business_entity.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class BusinessEntity < Model
3 |
4 | attr_accessor :id, :name, :status, :deleted, :created_at, :resource_version, :updated_at
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.create_transfers(params, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {
13 | :isIdempotent => true
14 | }
15 | Request.send('post', uri_path("business_entities","transfers"), params, env, headers,nil, false, jsonKeys, options)
16 | end
17 |
18 | def self.get_transfers(params={}, env=nil, headers={})
19 | jsonKeys = {
20 | }
21 | options = {}
22 | Request.send('get', uri_path("business_entities","transfers"), params, env, headers,nil, false, jsonKeys, options)
23 | end
24 |
25 | end # ~BusinessEntity
26 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/business_entity_transfer.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class BusinessEntityTransfer < Model
3 |
4 | attr_accessor :id, :resource_type, :resource_id, :active_resource_id, :destination_business_entity_id,
5 | :source_business_entity_id, :reason_code, :created_at
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | end # ~BusinessEntityTransfer
11 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/card.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Card < Model
3 |
4 | attr_accessor :payment_source_id, :status, :gateway, :gateway_account_id, :ref_tx_id, :first_name,
5 | :last_name, :iin, :last4, :card_type, :funding_type, :expiry_month, :expiry_year, :issuing_country,
6 | :billing_addr1, :billing_addr2, :billing_city, :billing_state_code, :billing_state, :billing_country,
7 | :billing_zip, :created_at, :resource_version, :updated_at, :ip_address, :powered_by, :customer_id,
8 | :masked_number
9 |
10 | # OPERATIONS
11 | #-----------
12 |
13 | def self.retrieve(id, env=nil, headers={})
14 | jsonKeys = {
15 | }
16 | options = {}
17 | Request.send('get', uri_path("cards",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
18 | end
19 |
20 | def self.update_card_for_customer(id, params, env=nil, headers={})
21 | jsonKeys = {
22 | }
23 | options = {
24 | :isIdempotent => true
25 | }
26 | Request.send('post', uri_path("customers",id.to_s,"credit_card"), params, env, headers,nil, false, jsonKeys, options)
27 | end
28 |
29 | def self.switch_gateway_for_customer(id, params, env=nil, headers={})
30 | jsonKeys = {
31 | }
32 | options = {
33 | :isIdempotent => true
34 | }
35 | Request.send('post', uri_path("customers",id.to_s,"switch_gateway"), params, env, headers,nil, false, jsonKeys, options)
36 | end
37 |
38 | def self.copy_card_for_customer(id, params, env=nil, headers={})
39 | jsonKeys = {
40 | }
41 | options = {
42 | :isIdempotent => true
43 | }
44 | Request.send('post', uri_path("customers",id.to_s,"copy_card"), params, env, headers,nil, false, jsonKeys, options)
45 | end
46 |
47 | def self.delete_card_for_customer(id, env=nil, headers={})
48 | jsonKeys = {
49 | }
50 | options = {
51 | :isIdempotent => true
52 | }
53 | Request.send('post', uri_path("customers",id.to_s,"delete_card"), {}, env, headers,nil, false, jsonKeys, options)
54 | end
55 |
56 | end # ~Card
57 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/comment.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Comment < Model
3 |
4 | attr_accessor :id, :entity_type, :added_by, :notes, :created_at, :type, :entity_id, :business_entity_id
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.create(params, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {
13 | :isIdempotent => true
14 | }
15 | Request.send('post', uri_path("comments"), params, env, headers,nil, false, jsonKeys, options)
16 | end
17 |
18 | def self.retrieve(id, env=nil, headers={})
19 | jsonKeys = {
20 | }
21 | options = {}
22 | Request.send('get', uri_path("comments",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
23 | end
24 |
25 | def self.list(params={}, env=nil, headers={})
26 | jsonKeys = {
27 | }
28 | options = {}
29 | Request.send_list_request('get', uri_path("comments"), params, env, headers,nil, false, jsonKeys, options)
30 | end
31 |
32 | def self.delete(id, env=nil, headers={})
33 | jsonKeys = {
34 | }
35 | options = {
36 | :isIdempotent => true
37 | }
38 | Request.send('post', uri_path("comments",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
39 | end
40 |
41 | end # ~Comment
42 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/configuration.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Configuration < Model
3 |
4 | attr_accessor :domain, :product_catalog_version, :chargebee_response_schema_type
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.list(env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {}
13 | Request.send_list_request('get', uri_path("configurations"), {}, env, headers,nil, false, jsonKeys, options)
14 | end
15 |
16 | end # ~Configuration
17 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/contact.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Contact < Model
3 |
4 | attr_accessor :id, :first_name, :last_name, :email, :phone, :label, :enabled, :send_account_email,
5 | :send_billing_email
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | end # ~Contact
11 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/contract_term.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ContractTerm < Model
3 |
4 | attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end,
5 | :total_contract_value, :total_contract_value_before_tax, :cancellation_cutoff_period, :created_at,
6 | :subscription_id, :remaining_billing_cycles
7 |
8 | # OPERATIONS
9 | #-----------
10 |
11 | end # ~ContractTerm
12 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/coupon.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Coupon < Model
3 |
4 | class ItemConstraint < Model
5 | attr_accessor :item_type, :constraint, :item_price_ids
6 | end
7 |
8 | class ItemConstraintCriteria < Model
9 | attr_accessor :item_type, :currencies, :item_family_ids, :item_price_periods
10 | end
11 |
12 | class CouponConstraint < Model
13 | attr_accessor :entity_type, :type, :value
14 | end
15 |
16 | attr_accessor :id, :name, :invoice_name, :discount_type, :discount_percentage, :discount_amount,
17 | :discount_quantity, :currency_code, :duration_type, :duration_month, :valid_from, :valid_till,
18 | :max_redemptions, :status, :apply_discount_on, :apply_on, :plan_constraint, :addon_constraint,
19 | :created_at, :archived_at, :resource_version, :updated_at, :included_in_mrr, :period, :period_unit,
20 | :plan_ids, :addon_ids, :item_constraints, :item_constraint_criteria, :redemptions, :invoice_notes,
21 | :meta_data, :coupon_constraints, :deleted
22 |
23 | # OPERATIONS
24 | #-----------
25 |
26 | def self.create(params, env=nil, headers={})
27 | jsonKeys = {
28 | :meta_data => 0,
29 | }
30 | options = {
31 | :isIdempotent => true
32 | }
33 | Request.send('post', uri_path("coupons"), params, env, headers,nil, false, jsonKeys, options)
34 | end
35 |
36 | def self.create_for_items(params, env=nil, headers={})
37 | jsonKeys = {
38 | :meta_data => 0,
39 | :item_price_ids => 1,
40 | :item_family_ids => 1,
41 | :currencies => 1,
42 | :item_price_periods => 1,
43 | }
44 | options = {
45 | :isIdempotent => true
46 | }
47 | Request.send('post', uri_path("coupons","create_for_items"), params, env, headers,nil, false, jsonKeys, options)
48 | end
49 |
50 | def self.update_for_items(id, params, env=nil, headers={})
51 | jsonKeys = {
52 | :meta_data => 0,
53 | :item_price_ids => 1,
54 | :item_family_ids => 1,
55 | :currencies => 1,
56 | :item_price_periods => 1,
57 | }
58 | options = {
59 | :isIdempotent => true
60 | }
61 | Request.send('post', uri_path("coupons",id.to_s,"update_for_items"), params, env, headers,nil, false, jsonKeys, options)
62 | end
63 |
64 | def self.list(params={}, env=nil, headers={})
65 | jsonKeys = {
66 | }
67 | options = {}
68 | Request.send_list_request('get', uri_path("coupons"), params, env, headers,nil, false, jsonKeys, options)
69 | end
70 |
71 | def self.retrieve(id, env=nil, headers={})
72 | jsonKeys = {
73 | }
74 | options = {}
75 | Request.send('get', uri_path("coupons",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
76 | end
77 |
78 | def self.update(id, params={}, env=nil, headers={})
79 | jsonKeys = {
80 | :meta_data => 0,
81 | }
82 | options = {
83 | :isIdempotent => true
84 | }
85 | Request.send('post', uri_path("coupons",id.to_s), params, env, headers,nil, false, jsonKeys, options)
86 | end
87 |
88 | def self.delete(id, env=nil, headers={})
89 | jsonKeys = {
90 | }
91 | options = {
92 | :isIdempotent => true
93 | }
94 | Request.send('post', uri_path("coupons",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
95 | end
96 |
97 | def self.copy(params, env=nil, headers={})
98 | jsonKeys = {
99 | }
100 | options = {
101 | :isIdempotent => true
102 | }
103 | Request.send('post', uri_path("coupons","copy"), params, env, headers,nil, false, jsonKeys, options)
104 | end
105 |
106 | def self.unarchive(id, env=nil, headers={})
107 | jsonKeys = {
108 | }
109 | options = {
110 | :isIdempotent => true
111 | }
112 | Request.send('post', uri_path("coupons",id.to_s,"unarchive"), {}, env, headers,nil, false, jsonKeys, options)
113 | end
114 |
115 | end # ~Coupon
116 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/coupon_code.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class CouponCode < Model
3 |
4 | attr_accessor :code, :status, :coupon_id, :coupon_set_id, :coupon_set_name
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.create(params, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {
13 | :isIdempotent => true
14 | }
15 | Request.send('post', uri_path("coupon_codes"), params, env, headers,nil, false, jsonKeys, options)
16 | end
17 |
18 | def self.retrieve(id, env=nil, headers={})
19 | jsonKeys = {
20 | }
21 | options = {}
22 | Request.send('get', uri_path("coupon_codes",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
23 | end
24 |
25 | def self.list(params={}, env=nil, headers={})
26 | jsonKeys = {
27 | }
28 | options = {}
29 | Request.send_list_request('get', uri_path("coupon_codes"), params, env, headers,nil, false, jsonKeys, options)
30 | end
31 |
32 | def self.archive(id, env=nil, headers={})
33 | jsonKeys = {
34 | }
35 | options = {
36 | :isIdempotent => true
37 | }
38 | Request.send('post', uri_path("coupon_codes",id.to_s,"archive"), {}, env, headers,nil, false, jsonKeys, options)
39 | end
40 |
41 | end # ~CouponCode
42 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/coupon_set.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class CouponSet < Model
3 |
4 | attr_accessor :id, :coupon_id, :name, :total_count, :redeemed_count, :archived_count, :meta_data
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.create(params, env=nil, headers={})
10 | jsonKeys = {
11 | :meta_data => 0,
12 | }
13 | options = {
14 | :isIdempotent => true
15 | }
16 | Request.send('post', uri_path("coupon_sets"), params, env, headers,nil, false, jsonKeys, options)
17 | end
18 |
19 | def self.add_coupon_codes(id, params={}, env=nil, headers={})
20 | jsonKeys = {
21 | }
22 | options = {
23 | :isIdempotent => true
24 | }
25 | Request.send('post', uri_path("coupon_sets",id.to_s,"add_coupon_codes"), params, env, headers,nil, false, jsonKeys, options)
26 | end
27 |
28 | def self.list(params={}, env=nil, headers={})
29 | jsonKeys = {
30 | }
31 | options = {}
32 | Request.send_list_request('get', uri_path("coupon_sets"), params, env, headers,nil, false, jsonKeys, options)
33 | end
34 |
35 | def self.retrieve(id, env=nil, headers={})
36 | jsonKeys = {
37 | }
38 | options = {}
39 | Request.send('get', uri_path("coupon_sets",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
40 | end
41 |
42 | def self.update(id, params={}, env=nil, headers={})
43 | jsonKeys = {
44 | :meta_data => 0,
45 | }
46 | options = {
47 | :isIdempotent => true
48 | }
49 | Request.send('post', uri_path("coupon_sets",id.to_s,"update"), params, env, headers,nil, false, jsonKeys, options)
50 | end
51 |
52 | def self.delete(id, env=nil, headers={})
53 | jsonKeys = {
54 | }
55 | options = {
56 | :isIdempotent => true
57 | }
58 | Request.send('post', uri_path("coupon_sets",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
59 | end
60 |
61 | def self.delete_unused_coupon_codes(id, env=nil, headers={})
62 | jsonKeys = {
63 | }
64 | options = {
65 | :isIdempotent => true
66 | }
67 | Request.send('post', uri_path("coupon_sets",id.to_s,"delete_unused_coupon_codes"), {}, env, headers,nil, false, jsonKeys, options)
68 | end
69 |
70 | end # ~CouponSet
71 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/credit_note_estimate.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class CreditNoteEstimate < Model
3 |
4 | class LineItem < Model
5 | attr_accessor :id, :subscription_id, :date_from, :date_to, :unit_amount, :quantity, :amount, :pricing_model, :is_taxed, :tax_amount, :tax_rate, :unit_amount_in_decimal, :quantity_in_decimal, :amount_in_decimal, :discount_amount, :item_level_discount_amount, :metered, :is_percentage_pricing, :reference_line_item_id, :description, :entity_description, :entity_type, :tax_exempt_reason, :entity_id, :customer_id
6 | end
7 |
8 | class LineItemTier < Model
9 | attr_accessor :line_item_id, :starting_unit, :ending_unit, :quantity_used, :unit_amount, :starting_unit_in_decimal, :ending_unit_in_decimal, :quantity_used_in_decimal, :unit_amount_in_decimal, :pricing_type, :package_size
10 | end
11 |
12 | class LineItemDiscount < Model
13 | attr_accessor :line_item_id, :discount_type, :coupon_id, :entity_id, :discount_amount
14 | end
15 |
16 | class LineItemTax < Model
17 | attr_accessor :line_item_id, :tax_name, :tax_rate, :date_to, :date_from, :prorated_taxable_amount, :is_partial_tax_applied, :is_non_compliance_tax, :taxable_amount, :tax_amount, :tax_juris_type, :tax_juris_name, :tax_juris_code, :tax_amount_in_local_currency, :local_currency_code
18 | end
19 |
20 | class Discount < Model
21 | attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
22 | end
23 |
24 | class Tax < Model
25 | attr_accessor :name, :amount, :description
26 | end
27 |
28 | attr_accessor :reference_invoice_id, :type, :price_type, :currency_code, :sub_total, :total,
29 | :amount_allocated, :amount_available, :line_items, :line_item_tiers, :line_item_discounts, :line_item_taxes,
30 | :discounts, :taxes, :round_off_amount, :customer_id
31 |
32 | # OPERATIONS
33 | #-----------
34 |
35 | end # ~CreditNoteEstimate
36 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/csv_tax_rule.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class CsvTaxRule < Model
3 |
4 | attr_accessor :tax_profile_name, :country, :state, :zip_code, :zip_code_start, :zip_code_end,
5 | :tax1_name, :tax1_rate, :tax1_juris_type, :tax1_juris_name, :tax1_juris_code, :tax2_name, :tax2_rate,
6 | :tax2_juris_type, :tax2_juris_name, :tax2_juris_code, :tax3_name, :tax3_rate, :tax3_juris_type,
7 | :tax3_juris_name, :tax3_juris_code, :tax4_name, :tax4_rate, :tax4_juris_type, :tax4_juris_name,
8 | :tax4_juris_code, :status, :time_zone, :valid_from, :valid_till, :service_type, :rule_weight,
9 | :overwrite
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | def self.create(params={}, env=nil, headers={})
15 | Request.send('post', uri_path("csv_tax_rules"), params, env, headers)
16 | end
17 |
18 | end # ~CsvTaxRule
19 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/currency.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Currency < Model
3 |
4 | attr_accessor :id, :enabled, :forex_type, :currency_code, :is_base_currency, :manual_exchange_rate
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.list(params={}, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {}
13 | Request.send_list_request('get', uri_path("currencies","list"), params, env, headers,nil, false, jsonKeys, options)
14 | end
15 |
16 | def self.retrieve(id, env=nil, headers={})
17 | jsonKeys = {
18 | }
19 | options = {}
20 | Request.send('get', uri_path("currencies",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
21 | end
22 |
23 | def self.create(params, env=nil, headers={})
24 | jsonKeys = {
25 | }
26 | options = {
27 | :isIdempotent => true
28 | }
29 | Request.send('post', uri_path("currencies"), params, env, headers,nil, false, jsonKeys, options)
30 | end
31 |
32 | def self.update(id, params, env=nil, headers={})
33 | jsonKeys = {
34 | }
35 | options = {
36 | :isIdempotent => true
37 | }
38 | Request.send('post', uri_path("currencies",id.to_s), params, env, headers,nil, false, jsonKeys, options)
39 | end
40 |
41 | def self.add_schedule(id, params, env=nil, headers={})
42 | jsonKeys = {
43 | }
44 | options = {
45 | :isIdempotent => true
46 | }
47 | Request.send('post', uri_path("currencies",id.to_s,"add_schedule"), params, env, headers,nil, false, jsonKeys, options)
48 | end
49 |
50 | def self.remove_schedule(id, env=nil, headers={})
51 | jsonKeys = {
52 | }
53 | options = {
54 | :isIdempotent => true
55 | }
56 | Request.send('post', uri_path("currencies",id.to_s,"remove_schedule"), {}, env, headers,nil, false, jsonKeys, options)
57 | end
58 |
59 | end # ~Currency
60 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/customer_entitlement.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class CustomerEntitlement < Model
3 |
4 | attr_accessor :customer_id, :subscription_id, :feature_id, :value, :name, :is_enabled
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.entitlements_for_customer(id, params={}, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {}
13 | Request.send('get', uri_path("customers",id.to_s,"customer_entitlements"), params, env, headers,nil, false, jsonKeys, options)
14 | end
15 |
16 | end # ~CustomerEntitlement
17 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/differential_price.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class DifferentialPrice < Model
3 |
4 | class Tier < Model
5 | attr_accessor :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :pricing_type, :package_size
6 | end
7 |
8 | class ParentPeriod < Model
9 | attr_accessor :period_unit, :period
10 | end
11 |
12 | attr_accessor :id, :item_price_id, :parent_item_id, :price, :price_in_decimal, :status, :resource_version,
13 | :updated_at, :created_at, :modified_at, :tiers, :currency_code, :parent_periods, :business_entity_id,
14 | :deleted
15 |
16 | # OPERATIONS
17 | #-----------
18 |
19 | def self.create(id, params, env=nil, headers={})
20 | jsonKeys = {
21 | :period => 1,
22 | }
23 | options = {
24 | :isIdempotent => true
25 | }
26 | Request.send('post', uri_path("item_prices",id.to_s,"differential_prices"), params, env, headers,nil, false, jsonKeys, options)
27 | end
28 |
29 | def self.retrieve(id, params, env=nil, headers={})
30 | jsonKeys = {
31 | }
32 | options = {}
33 | Request.send('get', uri_path("differential_prices",id.to_s), params, env, headers,nil, false, jsonKeys, options)
34 | end
35 |
36 | def self.update(id, params, env=nil, headers={})
37 | jsonKeys = {
38 | :period => 1,
39 | }
40 | options = {
41 | :isIdempotent => true
42 | }
43 | Request.send('post', uri_path("differential_prices",id.to_s), params, env, headers,nil, false, jsonKeys, options)
44 | end
45 |
46 | def self.delete(id, params, env=nil, headers={})
47 | jsonKeys = {
48 | }
49 | options = {
50 | :isIdempotent => true
51 | }
52 | Request.send('post', uri_path("differential_prices",id.to_s,"delete"), params, env, headers,nil, false, jsonKeys, options)
53 | end
54 |
55 | def self.list(params={}, env=nil, headers={})
56 | jsonKeys = {
57 | }
58 | options = {}
59 | Request.send_list_request('get', uri_path("differential_prices"), params, env, headers,nil, false, jsonKeys, options)
60 | end
61 |
62 | end # ~DifferentialPrice
63 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/discount.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Discount < Model
3 |
4 | attr_accessor :id, :invoice_name, :type, :percentage, :amount, :quantity, :currency_code, :duration_type,
5 | :period, :period_unit, :included_in_mrr, :apply_on, :item_price_id, :created_at, :apply_till,
6 | :applied_count, :coupon_id, :index
7 |
8 | # OPERATIONS
9 | #-----------
10 |
11 | end # ~Discount
12 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/download.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Download < Model
3 |
4 | attr_accessor :download_url, :valid_till, :mime_type
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~Download
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/entitlement.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Entitlement < Model
3 |
4 | attr_accessor :id, :entity_id, :entity_type, :feature_id, :feature_name, :value, :name
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.list(params={}, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {}
13 | Request.send_list_request('get', uri_path("entitlements"), params, env, headers,nil, false, jsonKeys, options)
14 | end
15 |
16 | def self.create(params, env=nil, headers={})
17 | jsonKeys = {
18 | }
19 | options = {
20 | :isIdempotent => true
21 | }
22 | Request.send('post', uri_path("entitlements"), params, env, headers,nil, false, jsonKeys, options)
23 | end
24 |
25 | end # ~Entitlement
26 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/entitlement_override.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class EntitlementOverride < Model
3 |
4 | attr_accessor :id, :entity_id, :entity_type, :feature_id, :feature_name, :value, :name, :expires_at,
5 | :effective_from, :schedule_status
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.add_entitlement_override_for_subscription(id, params, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {
14 | :isIdempotent => true
15 | }
16 | Request.send('post', uri_path("subscriptions",id.to_s,"entitlement_overrides"), params, env, headers,nil, false, jsonKeys, options)
17 | end
18 |
19 | def self.list_entitlement_override_for_subscription(id, params={}, env=nil, headers={})
20 | jsonKeys = {
21 | }
22 | options = {}
23 | Request.send('get', uri_path("subscriptions",id.to_s,"entitlement_overrides"), params, env, headers,nil, false, jsonKeys, options)
24 | end
25 |
26 | end # ~EntitlementOverride
27 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/estimate.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Estimate < Model
3 |
4 | attr_accessor :created_at, :subscription_estimate, :subscription_estimates, :invoice_estimate,
5 | :invoice_estimates, :payment_schedule_estimates, :next_invoice_estimate, :credit_note_estimates,
6 | :unbilled_charge_estimates
7 |
8 | # OPERATIONS
9 | #-----------
10 |
11 | def self.create_subscription(params, env=nil, headers={})
12 | jsonKeys = {
13 | :exemption_details => 1,
14 | }
15 | options = {}
16 | Request.send('post', uri_path("estimates","create_subscription"), params, env, headers,nil, false, jsonKeys, options)
17 | end
18 |
19 | def self.create_sub_item_estimate(params, env=nil, headers={})
20 | jsonKeys = {
21 | :exemption_details => 1,
22 | }
23 | options = {}
24 | Request.send('post', uri_path("estimates","create_subscription_for_items"), params, env, headers,nil, false, jsonKeys, options)
25 | end
26 |
27 | def self.create_sub_for_customer_estimate(id, params, env=nil, headers={})
28 | jsonKeys = {
29 | }
30 | options = {}
31 | Request.send('get', uri_path("customers",id.to_s,"create_subscription_estimate"), params, env, headers,nil, false, jsonKeys, options)
32 | end
33 |
34 | def self.create_sub_item_for_customer_estimate(id, params, env=nil, headers={})
35 | jsonKeys = {
36 | }
37 | options = {}
38 | Request.send('post', uri_path("customers",id.to_s,"create_subscription_for_items_estimate"), params, env, headers,nil, false, jsonKeys, options)
39 | end
40 |
41 | def self.update_subscription(params, env=nil, headers={})
42 | jsonKeys = {
43 | }
44 | options = {}
45 | Request.send('post', uri_path("estimates","update_subscription"), params, env, headers,nil, false, jsonKeys, options)
46 | end
47 |
48 | def self.update_subscription_for_items(params, env=nil, headers={})
49 | jsonKeys = {
50 | }
51 | options = {}
52 | Request.send('post', uri_path("estimates","update_subscription_for_items"), params, env, headers,nil, false, jsonKeys, options)
53 | end
54 |
55 | def self.renewal_estimate(id, params={}, env=nil, headers={})
56 | jsonKeys = {
57 | }
58 | options = {}
59 | Request.send('get', uri_path("subscriptions",id.to_s,"renewal_estimate"), params, env, headers,nil, false, jsonKeys, options)
60 | end
61 |
62 | def self.advance_invoice_estimate(id, params={}, env=nil, headers={})
63 | jsonKeys = {
64 | }
65 | options = {}
66 | Request.send('post', uri_path("subscriptions",id.to_s,"advance_invoice_estimate"), params, env, headers,nil, false, jsonKeys, options)
67 | end
68 |
69 | def self.regenerate_invoice_estimate(id, params={}, env=nil, headers={})
70 | jsonKeys = {
71 | }
72 | options = {}
73 | Request.send('post', uri_path("subscriptions",id.to_s,"regenerate_invoice_estimate"), params, env, headers,nil, false, jsonKeys, options)
74 | end
75 |
76 | def self.upcoming_invoices_estimate(id, env=nil, headers={})
77 | jsonKeys = {
78 | }
79 | options = {}
80 | Request.send('get', uri_path("customers",id.to_s,"upcoming_invoices_estimate"), {}, env, headers,nil, false, jsonKeys, options)
81 | end
82 |
83 | def self.change_term_end(id, params, env=nil, headers={})
84 | jsonKeys = {
85 | }
86 | options = {}
87 | Request.send('post', uri_path("subscriptions",id.to_s,"change_term_end_estimate"), params, env, headers,nil, false, jsonKeys, options)
88 | end
89 |
90 | def self.cancel_subscription(id, params={}, env=nil, headers={})
91 | jsonKeys = {
92 | }
93 | options = {}
94 | Request.send('post', uri_path("subscriptions",id.to_s,"cancel_subscription_estimate"), params, env, headers,nil, false, jsonKeys, options)
95 | end
96 |
97 | def self.cancel_subscription_for_items(id, params={}, env=nil, headers={})
98 | jsonKeys = {
99 | }
100 | options = {}
101 | Request.send('post', uri_path("subscriptions",id.to_s,"cancel_subscription_for_items_estimate"), params, env, headers,nil, false, jsonKeys, options)
102 | end
103 |
104 | def self.pause_subscription(id, params={}, env=nil, headers={})
105 | jsonKeys = {
106 | }
107 | options = {}
108 | Request.send('post', uri_path("subscriptions",id.to_s,"pause_subscription_estimate"), params, env, headers,nil, false, jsonKeys, options)
109 | end
110 |
111 | def self.resume_subscription(id, params={}, env=nil, headers={})
112 | jsonKeys = {
113 | }
114 | options = {}
115 | Request.send('post', uri_path("subscriptions",id.to_s,"resume_subscription_estimate"), params, env, headers,nil, false, jsonKeys, options)
116 | end
117 |
118 | def self.gift_subscription(params, env=nil, headers={})
119 | jsonKeys = {
120 | :additional_information => 1,
121 | }
122 | options = {}
123 | Request.send('post', uri_path("estimates","gift_subscription"), params, env, headers,nil, false, jsonKeys, options)
124 | end
125 |
126 | def self.gift_subscription_for_items(params, env=nil, headers={})
127 | jsonKeys = {
128 | :additional_information => 1,
129 | }
130 | options = {}
131 | Request.send('post', uri_path("estimates","gift_subscription_for_items"), params, env, headers,nil, false, jsonKeys, options)
132 | end
133 |
134 | def self.create_invoice(params={}, env=nil, headers={})
135 | jsonKeys = {
136 | }
137 | options = {}
138 | Request.send('post', uri_path("estimates","create_invoice"), params, env, headers,nil, false, jsonKeys, options)
139 | end
140 |
141 | def self.create_invoice_for_items(params, env=nil, headers={})
142 | jsonKeys = {
143 | }
144 | options = {}
145 | Request.send('post', uri_path("estimates","create_invoice_for_items"), params, env, headers,nil, false, jsonKeys, options)
146 | end
147 |
148 | def self.payment_schedules(params, env=nil, headers={})
149 | jsonKeys = {
150 | }
151 | options = {
152 | :isIdempotent => true
153 | }
154 | Request.send('post', uri_path("estimates","payment_schedules"), params, env, headers,nil, false, jsonKeys, options)
155 | end
156 |
157 | end # ~Estimate
158 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/event.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Event < Model
3 |
4 | class Webhook < Model
5 | attr_accessor :id, :webhook_status
6 | end
7 |
8 | attr_accessor :id, :occurred_at, :source, :user, :webhook_status, :webhook_failure_reason, :webhooks,
9 | :event_type, :api_version, :origin_user
10 |
11 | class Content < Result
12 | end
13 |
14 | def content
15 | Content.new(@values[:content])
16 | end
17 |
18 | def self.deserialize(json)
19 | begin
20 | webhook_data = JSON.parse(json)
21 | rescue JSON::ParserError => e
22 | raise Error.new("Invalid webhook object to deserialize. #{e}",e)
23 | end
24 |
25 | api_version = webhook_data["api_version"]
26 | if api_version != nil && api_version.casecmp(Environment::API_VERSION) != 0
27 | raise Error.new("API version [#{api_version.upcase}] in response does not match with client library API version [#{Environment::API_VERSION.upcase}]")
28 | end
29 |
30 | webhook_data = Util.symbolize_keys(webhook_data)
31 | Event.construct(webhook_data)
32 | end
33 |
34 | # OPERATIONS
35 | #-----------
36 |
37 | def self.list(params={}, env=nil, headers={})
38 | jsonKeys = {
39 | }
40 | options = {}
41 | Request.send_list_request('get', uri_path("events"), params, env, headers,nil, false, jsonKeys, options)
42 | end
43 |
44 | def self.retrieve(id, env=nil, headers={})
45 | jsonKeys = {
46 | }
47 | options = {}
48 | Request.send('get', uri_path("events",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
49 | end
50 |
51 | end # ~Event
52 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/export.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Export < Model
3 |
4 | class Download < Model
5 | attr_accessor :download_url, :valid_till, :mime_type
6 | end
7 |
8 | attr_accessor :id, :operation_type, :mime_type, :status, :created_at, :download
9 |
10 | def wait_for_export_completion(env = nil, headers={})
11 | env = env || ChargeBee.default_env
12 | sleeptime = env.export_sleeptime
13 |
14 | export_final = (1..50).inject(self) do |export|
15 | break export if export.status != "in_process"
16 | sleep(sleeptime)
17 | self.class.retrieve(self.id, env, headers).export
18 | end
19 |
20 | # sync last fetched one with the current instance
21 | new_values = export_final.instance_variable_get("@values")
22 | self.instance_variable_set("@values", new_values)
23 | self.load(new_values)
24 |
25 | case export_final.status
26 | when "in_process"
27 | raise Error.new('Export is taking too long')
28 | when "failed"
29 | json_obj = Util.symbolize_keys(JSON.parse(self.error_json))
30 | raise OperationFailedError.new(json_obj[:http_code], json_obj)
31 | when "not_enabled", "_unknown"
32 | raise Error.new("Export status is in wrong state #{self.status}")
33 | end
34 | end
35 |
36 | # OPERATIONS
37 | #-----------
38 |
39 | def self.retrieve(id, env=nil, headers={})
40 | jsonKeys = {
41 | }
42 | options = {}
43 | Request.send('get', uri_path("exports",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
44 | end
45 |
46 | def self.revenue_recognition(params, env=nil, headers={})
47 | jsonKeys = {
48 | }
49 | options = {
50 | :isIdempotent => true
51 | }
52 | Request.send('post', uri_path("exports","revenue_recognition"), params, env, headers,nil, false, jsonKeys, options)
53 | end
54 |
55 | def self.deferred_revenue(params, env=nil, headers={})
56 | jsonKeys = {
57 | }
58 | options = {
59 | :isIdempotent => true
60 | }
61 | Request.send('post', uri_path("exports","deferred_revenue"), params, env, headers,nil, false, jsonKeys, options)
62 | end
63 |
64 | def self.plans(params={}, env=nil, headers={})
65 | jsonKeys = {
66 | }
67 | options = {
68 | :isIdempotent => true
69 | }
70 | Request.send('post', uri_path("exports","plans"), params, env, headers,nil, false, jsonKeys, options)
71 | end
72 |
73 | def self.addons(params={}, env=nil, headers={})
74 | jsonKeys = {
75 | }
76 | options = {
77 | :isIdempotent => true
78 | }
79 | Request.send('post', uri_path("exports","addons"), params, env, headers,nil, false, jsonKeys, options)
80 | end
81 |
82 | def self.coupons(params={}, env=nil, headers={})
83 | jsonKeys = {
84 | }
85 | options = {
86 | :isIdempotent => true
87 | }
88 | Request.send('post', uri_path("exports","coupons"), params, env, headers,nil, false, jsonKeys, options)
89 | end
90 |
91 | def self.customers(params={}, env=nil, headers={})
92 | jsonKeys = {
93 | }
94 | options = {
95 | :isIdempotent => true
96 | }
97 | Request.send('post', uri_path("exports","customers"), params, env, headers,nil, false, jsonKeys, options)
98 | end
99 |
100 | def self.subscriptions(params={}, env=nil, headers={})
101 | jsonKeys = {
102 | }
103 | options = {
104 | :isIdempotent => true
105 | }
106 | Request.send('post', uri_path("exports","subscriptions"), params, env, headers,nil, false, jsonKeys, options)
107 | end
108 |
109 | def self.invoices(params={}, env=nil, headers={})
110 | jsonKeys = {
111 | }
112 | options = {
113 | :isIdempotent => true
114 | }
115 | Request.send('post', uri_path("exports","invoices"), params, env, headers,nil, false, jsonKeys, options)
116 | end
117 |
118 | def self.credit_notes(params={}, env=nil, headers={})
119 | jsonKeys = {
120 | }
121 | options = {
122 | :isIdempotent => true
123 | }
124 | Request.send('post', uri_path("exports","credit_notes"), params, env, headers,nil, false, jsonKeys, options)
125 | end
126 |
127 | def self.transactions(params={}, env=nil, headers={})
128 | jsonKeys = {
129 | }
130 | options = {
131 | :isIdempotent => true
132 | }
133 | Request.send('post', uri_path("exports","transactions"), params, env, headers,nil, false, jsonKeys, options)
134 | end
135 |
136 | def self.orders(params={}, env=nil, headers={})
137 | jsonKeys = {
138 | }
139 | options = {
140 | :isIdempotent => true
141 | }
142 | Request.send('post', uri_path("exports","orders"), params, env, headers,nil, false, jsonKeys, options)
143 | end
144 |
145 | def self.item_families(params={}, env=nil, headers={})
146 | jsonKeys = {
147 | }
148 | options = {
149 | :isIdempotent => true
150 | }
151 | Request.send('post', uri_path("exports","item_families"), params, env, headers,nil, false, jsonKeys, options)
152 | end
153 |
154 | def self.items(params={}, env=nil, headers={})
155 | jsonKeys = {
156 | }
157 | options = {
158 | :isIdempotent => true
159 | }
160 | Request.send('post', uri_path("exports","items"), params, env, headers,nil, false, jsonKeys, options)
161 | end
162 |
163 | def self.item_prices(params={}, env=nil, headers={})
164 | jsonKeys = {
165 | }
166 | options = {
167 | :isIdempotent => true
168 | }
169 | Request.send('post', uri_path("exports","item_prices"), params, env, headers,nil, false, jsonKeys, options)
170 | end
171 |
172 | def self.attached_items(params={}, env=nil, headers={})
173 | jsonKeys = {
174 | }
175 | options = {
176 | :isIdempotent => true
177 | }
178 | Request.send('post', uri_path("exports","attached_items"), params, env, headers,nil, false, jsonKeys, options)
179 | end
180 |
181 | def self.differential_prices(params={}, env=nil, headers={})
182 | jsonKeys = {
183 | }
184 | options = {
185 | :isIdempotent => true
186 | }
187 | Request.send('post', uri_path("exports","differential_prices"), params, env, headers,nil, false, jsonKeys, options)
188 | end
189 |
190 | def self.price_variants(params={}, env=nil, headers={})
191 | jsonKeys = {
192 | }
193 | options = {
194 | :isIdempotent => true
195 | }
196 | Request.send('post', uri_path("exports","price_variants"), params, env, headers,nil, false, jsonKeys, options)
197 | end
198 |
199 | end # ~Export
200 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/feature.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Feature < Model
3 |
4 | class Level < Model
5 | attr_accessor :name, :value, :level, :is_unlimited
6 | end
7 |
8 | attr_accessor :id, :name, :description, :status, :type, :unit, :resource_version, :updated_at,
9 | :created_at, :levels
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | def self.list(params={}, env=nil, headers={})
15 | jsonKeys = {
16 | }
17 | options = {}
18 | Request.send_list_request('get', uri_path("features"), params, env, headers,nil, false, jsonKeys, options)
19 | end
20 |
21 | def self.create(params, env=nil, headers={})
22 | jsonKeys = {
23 | }
24 | options = {
25 | :isIdempotent => true
26 | }
27 | Request.send('post', uri_path("features"), params, env, headers,nil, false, jsonKeys, options)
28 | end
29 |
30 | def self.update(id, params={}, env=nil, headers={})
31 | jsonKeys = {
32 | }
33 | options = {
34 | :isIdempotent => true
35 | }
36 | Request.send('post', uri_path("features",id.to_s), params, env, headers,nil, false, jsonKeys, options)
37 | end
38 |
39 | def self.retrieve(id, env=nil, headers={})
40 | jsonKeys = {
41 | }
42 | options = {}
43 | Request.send('get', uri_path("features",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
44 | end
45 |
46 | def self.delete(id, env=nil, headers={})
47 | jsonKeys = {
48 | }
49 | options = {
50 | :isIdempotent => true
51 | }
52 | Request.send('post', uri_path("features",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
53 | end
54 |
55 | def self.activate(id, env=nil, headers={})
56 | jsonKeys = {
57 | }
58 | options = {
59 | :isIdempotent => true
60 | }
61 | Request.send('post', uri_path("features",id.to_s,"activate_command"), {}, env, headers,nil, false, jsonKeys, options)
62 | end
63 |
64 | def self.archive(id, env=nil, headers={})
65 | jsonKeys = {
66 | }
67 | options = {
68 | :isIdempotent => true
69 | }
70 | Request.send('post', uri_path("features",id.to_s,"archive_command"), {}, env, headers,nil, false, jsonKeys, options)
71 | end
72 |
73 | def self.reactivate(id, env=nil, headers={})
74 | jsonKeys = {
75 | }
76 | options = {
77 | :isIdempotent => true
78 | }
79 | Request.send('post', uri_path("features",id.to_s,"reactivate_command"), {}, env, headers,nil, false, jsonKeys, options)
80 | end
81 |
82 | end # ~Feature
83 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/gateway_error_detail.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class GatewayErrorDetail < Model
3 |
4 | attr_accessor :request_id, :error_category, :error_code, :error_message, :decline_code, :decline_message,
5 | :network_error_code, :network_error_message, :error_field, :recommendation_code, :recommendation_message,
6 | :processor_error_code, :processor_error_message, :error_cause_id, :processor_advice_code
7 |
8 | # OPERATIONS
9 | #-----------
10 |
11 | end # ~GatewayErrorDetail
12 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/gift.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Gift < Model
3 |
4 | class Gifter < Model
5 | attr_accessor :customer_id, :invoice_id, :signature, :note
6 | end
7 |
8 | class GiftReceiver < Model
9 | attr_accessor :customer_id, :subscription_id, :first_name, :last_name, :email
10 | end
11 |
12 | class GiftTimeline < Model
13 | attr_accessor :status, :occurred_at
14 | end
15 |
16 | attr_accessor :id, :status, :scheduled_at, :auto_claim, :no_expiry, :claim_expiry_date, :resource_version,
17 | :updated_at, :gifter, :gift_receiver, :gift_timelines
18 |
19 | # OPERATIONS
20 | #-----------
21 |
22 | def self.create(params, env=nil, headers={})
23 | jsonKeys = {
24 | :additional_information => 1,
25 | }
26 | options = {
27 | :isIdempotent => true
28 | }
29 | Request.send('post', uri_path("gifts"), params, env, headers,nil, false, jsonKeys, options)
30 | end
31 |
32 | def self.create_for_items(params, env=nil, headers={})
33 | jsonKeys = {
34 | :additional_information => 1,
35 | }
36 | options = {
37 | :isIdempotent => true
38 | }
39 | Request.send('post', uri_path("gifts","create_for_items"), params, env, headers,nil, false, jsonKeys, options)
40 | end
41 |
42 | def self.retrieve(id, env=nil, headers={})
43 | jsonKeys = {
44 | }
45 | options = {}
46 | Request.send('get', uri_path("gifts",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
47 | end
48 |
49 | def self.list(params={}, env=nil, headers={})
50 | jsonKeys = {
51 | }
52 | options = {}
53 | Request.send_list_request('get', uri_path("gifts"), params, env, headers,nil, false, jsonKeys, options)
54 | end
55 |
56 | def self.claim(id, env=nil, headers={})
57 | jsonKeys = {
58 | }
59 | options = {
60 | :isIdempotent => true
61 | }
62 | Request.send('post', uri_path("gifts",id.to_s,"claim"), {}, env, headers,nil, false, jsonKeys, options)
63 | end
64 |
65 | def self.cancel(id, env=nil, headers={})
66 | jsonKeys = {
67 | }
68 | options = {
69 | :isIdempotent => true
70 | }
71 | Request.send('post', uri_path("gifts",id.to_s,"cancel"), {}, env, headers,nil, false, jsonKeys, options)
72 | end
73 |
74 | def self.update_gift(id, params, env=nil, headers={})
75 | jsonKeys = {
76 | }
77 | options = {
78 | :isIdempotent => true
79 | }
80 | Request.send('post', uri_path("gifts",id.to_s,"update_gift"), params, env, headers,nil, false, jsonKeys, options)
81 | end
82 |
83 | end # ~Gift
84 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/hierarchy.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Hierarchy < Model
3 |
4 | attr_accessor :customer_id, :parent_id, :payment_owner_id, :invoice_owner_id, :has_children,
5 | :children_ids
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | end # ~Hierarchy
11 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/hosted_page.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class HostedPage < Model
3 |
4 | attr_accessor :id, :type, :url, :state, :failure_reason, :pass_thru_content, :embed, :created_at,
5 | :expires_at, :updated_at, :resource_version, :checkout_info, :business_entity_id
6 |
7 | class Content < Result
8 | end
9 |
10 | def content
11 | if @values[:content].nil?
12 | nil
13 | else
14 | Content.new(@values[:content])
15 | end
16 | end
17 |
18 | # OPERATIONS
19 | #-----------
20 |
21 | def self.checkout_new(params, env=nil, headers={})
22 | jsonKeys = {
23 | }
24 | options = {
25 | :isIdempotent => true
26 | }
27 | Request.send('post', uri_path("hosted_pages","checkout_new"), params, env, headers,nil, false, jsonKeys, options)
28 | end
29 |
30 | def self.checkout_one_time(params={}, env=nil, headers={})
31 | jsonKeys = {
32 | }
33 | options = {
34 | :isIdempotent => true
35 | }
36 | Request.send('post', uri_path("hosted_pages","checkout_one_time"), params, env, headers,nil, false, jsonKeys, options)
37 | end
38 |
39 | def self.checkout_one_time_for_items(params, env=nil, headers={})
40 | jsonKeys = {
41 | }
42 | options = {
43 | :isIdempotent => true
44 | }
45 | Request.send('post', uri_path("hosted_pages","checkout_one_time_for_items"), params, env, headers,nil, false, jsonKeys, options)
46 | end
47 |
48 | def self.checkout_new_for_items(params, env=nil, headers={})
49 | jsonKeys = {
50 | }
51 | options = {
52 | :isIdempotent => true
53 | }
54 | Request.send('post', uri_path("hosted_pages","checkout_new_for_items"), params, env, headers,nil, false, jsonKeys, options)
55 | end
56 |
57 | def self.checkout_existing(params, env=nil, headers={})
58 | jsonKeys = {
59 | }
60 | options = {
61 | :isIdempotent => true
62 | }
63 | Request.send('post', uri_path("hosted_pages","checkout_existing"), params, env, headers,nil, false, jsonKeys, options)
64 | end
65 |
66 | def self.checkout_existing_for_items(params, env=nil, headers={})
67 | jsonKeys = {
68 | }
69 | options = {
70 | :isIdempotent => true
71 | }
72 | Request.send('post', uri_path("hosted_pages","checkout_existing_for_items"), params, env, headers,nil, false, jsonKeys, options)
73 | end
74 |
75 | def self.update_card(params, env=nil, headers={})
76 | jsonKeys = {
77 | }
78 | options = {
79 | :isIdempotent => true
80 | }
81 | Request.send('post', uri_path("hosted_pages","update_card"), params, env, headers,nil, false, jsonKeys, options)
82 | end
83 |
84 | def self.update_payment_method(params, env=nil, headers={})
85 | jsonKeys = {
86 | }
87 | options = {
88 | :isIdempotent => true
89 | }
90 | Request.send('post', uri_path("hosted_pages","update_payment_method"), params, env, headers,nil, false, jsonKeys, options)
91 | end
92 |
93 | def self.manage_payment_sources(params, env=nil, headers={})
94 | jsonKeys = {
95 | }
96 | options = {
97 | :isIdempotent => true
98 | }
99 | Request.send('post', uri_path("hosted_pages","manage_payment_sources"), params, env, headers,nil, false, jsonKeys, options)
100 | end
101 |
102 | def self.collect_now(params, env=nil, headers={})
103 | jsonKeys = {
104 | }
105 | options = {
106 | :isIdempotent => true
107 | }
108 | Request.send('post', uri_path("hosted_pages","collect_now"), params, env, headers,nil, false, jsonKeys, options)
109 | end
110 |
111 | def self.accept_quote(params, env=nil, headers={})
112 | jsonKeys = {
113 | }
114 | options = {
115 | :isIdempotent => true
116 | }
117 | Request.send('post', uri_path("hosted_pages","accept_quote"), params, env, headers,nil, false, jsonKeys, options)
118 | end
119 |
120 | def self.extend_subscription(params, env=nil, headers={})
121 | jsonKeys = {
122 | }
123 | options = {
124 | :isIdempotent => true
125 | }
126 | Request.send('post', uri_path("hosted_pages","extend_subscription"), params, env, headers,nil, false, jsonKeys, options)
127 | end
128 |
129 | def self.checkout_gift(params, env=nil, headers={})
130 | jsonKeys = {
131 | }
132 | options = {
133 | :isIdempotent => true
134 | }
135 | Request.send('post', uri_path("hosted_pages","checkout_gift"), params, env, headers,nil, false, jsonKeys, options)
136 | end
137 |
138 | def self.checkout_gift_for_items(params={}, env=nil, headers={})
139 | jsonKeys = {
140 | }
141 | options = {
142 | :isIdempotent => true
143 | }
144 | Request.send('post', uri_path("hosted_pages","checkout_gift_for_items"), params, env, headers,nil, false, jsonKeys, options)
145 | end
146 |
147 | def self.claim_gift(params, env=nil, headers={})
148 | jsonKeys = {
149 | }
150 | options = {
151 | :isIdempotent => true
152 | }
153 | Request.send('post', uri_path("hosted_pages","claim_gift"), params, env, headers,nil, false, jsonKeys, options)
154 | end
155 |
156 | def self.retrieve_agreement_pdf(params, env=nil, headers={})
157 | jsonKeys = {
158 | }
159 | options = {
160 | :isIdempotent => true
161 | }
162 | Request.send('post', uri_path("hosted_pages","retrieve_agreement_pdf"), params, env, headers,nil, false, jsonKeys, options)
163 | end
164 |
165 | def self.acknowledge(id, env=nil, headers={})
166 | jsonKeys = {
167 | }
168 | options = {
169 | :isIdempotent => true
170 | }
171 | Request.send('post', uri_path("hosted_pages",id.to_s,"acknowledge"), {}, env, headers,nil, false, jsonKeys, options)
172 | end
173 |
174 | def self.retrieve(id, env=nil, headers={})
175 | jsonKeys = {
176 | }
177 | options = {}
178 | Request.send('get', uri_path("hosted_pages",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
179 | end
180 |
181 | def self.list(params={}, env=nil, headers={})
182 | jsonKeys = {
183 | }
184 | options = {}
185 | Request.send_list_request('get', uri_path("hosted_pages"), params, env, headers,nil, false, jsonKeys, options)
186 | end
187 |
188 | def self.pre_cancel(params, env=nil, headers={})
189 | jsonKeys = {
190 | }
191 | options = {
192 | :isIdempotent => true
193 | }
194 | Request.send('post', uri_path("hosted_pages","pre_cancel"), params, env, headers,nil, false, jsonKeys, options)
195 | end
196 |
197 | def self.events(params, env=nil, headers={})
198 | jsonKeys = {
199 | :event_data => 0,
200 | }
201 | options = {
202 | :isIdempotent => true
203 | }
204 | Request.send('post', uri_path("hosted_pages","events"), params, env, headers,nil, false, jsonKeys, options)
205 | end
206 |
207 | def self.view_voucher(params, env=nil, headers={})
208 | jsonKeys = {
209 | }
210 | options = {
211 | :isIdempotent => true
212 | }
213 | Request.send('post', uri_path("hosted_pages","view_voucher"), params, env, headers,nil, false, jsonKeys, options)
214 | end
215 |
216 | end # ~HostedPage
217 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/impacted_customer.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ImpactedCustomer < Model
3 |
4 | class Download < Model
5 | attr_accessor :download_url, :valid_till, :mime_type
6 | end
7 |
8 | attr_accessor :action_type, :download
9 |
10 | # OPERATIONS
11 | #-----------
12 |
13 | end # ~ImpactedCustomer
14 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/impacted_item.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ImpactedItem < Model
3 |
4 | class Download < Model
5 | attr_accessor :download_url, :valid_till, :mime_type
6 | end
7 |
8 | attr_accessor :count, :download, :items
9 |
10 | # OPERATIONS
11 | #-----------
12 |
13 | end # ~ImpactedItem
14 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/impacted_item_price.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ImpactedItemPrice < Model
3 |
4 | class Download < Model
5 | attr_accessor :download_url, :valid_till, :mime_type
6 | end
7 |
8 | attr_accessor :count, :download, :item_prices
9 |
10 | # OPERATIONS
11 | #-----------
12 |
13 | end # ~ImpactedItemPrice
14 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/impacted_subscription.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ImpactedSubscription < Model
3 |
4 | class Download < Model
5 | attr_accessor :download_url, :valid_till, :mime_type
6 | end
7 |
8 | attr_accessor :count, :download, :subscription_ids
9 |
10 | # OPERATIONS
11 | #-----------
12 |
13 | end # ~ImpactedSubscription
14 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/in_app_subscription.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class InAppSubscription < Model
3 |
4 | attr_accessor :app_id, :subscription_id, :customer_id, :plan_id, :store_status, :invoice_id
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.process_receipt(id, params, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {
13 | :isIdempotent => true
14 | }
15 | Request.send('post', uri_path("in_app_subscriptions",id.to_s,"process_purchase_command"), params, env, headers,nil, false, jsonKeys, options)
16 | end
17 |
18 | def self.import_receipt(id, params, env=nil, headers={})
19 | jsonKeys = {
20 | }
21 | options = {
22 | :isIdempotent => true
23 | }
24 | Request.send('post', uri_path("in_app_subscriptions",id.to_s,"import_receipt"), params, env, headers,nil, false, jsonKeys, options)
25 | end
26 |
27 | def self.import_subscription(id, params, env=nil, headers={})
28 | jsonKeys = {
29 | }
30 | options = {
31 | :isIdempotent => true
32 | }
33 | Request.send('post', uri_path("in_app_subscriptions",id.to_s,"import_subscription"), params, env, headers,nil, false, jsonKeys, options)
34 | end
35 |
36 | def self.retrieve_store_subs(id, params, env=nil, headers={})
37 | jsonKeys = {
38 | }
39 | options = {
40 | :isIdempotent => true
41 | }
42 | Request.send('post', uri_path("in_app_subscriptions",id.to_s,"retrieve"), params, env, headers,nil, false, jsonKeys, options)
43 | end
44 |
45 | end # ~InAppSubscription
46 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/invoice_estimate.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class InvoiceEstimate < Model
3 |
4 | class LineItem < Model
5 | attr_accessor :id, :subscription_id, :date_from, :date_to, :unit_amount, :quantity, :amount, :pricing_model, :is_taxed, :tax_amount, :tax_rate, :unit_amount_in_decimal, :quantity_in_decimal, :amount_in_decimal, :discount_amount, :item_level_discount_amount, :metered, :is_percentage_pricing, :reference_line_item_id, :description, :entity_description, :entity_type, :tax_exempt_reason, :entity_id, :customer_id
6 | end
7 |
8 | class LineItemTier < Model
9 | attr_accessor :line_item_id, :starting_unit, :ending_unit, :quantity_used, :unit_amount, :starting_unit_in_decimal, :ending_unit_in_decimal, :quantity_used_in_decimal, :unit_amount_in_decimal, :pricing_type, :package_size
10 | end
11 |
12 | class LineItemDiscount < Model
13 | attr_accessor :line_item_id, :discount_type, :coupon_id, :entity_id, :discount_amount
14 | end
15 |
16 | class LineItemTax < Model
17 | attr_accessor :line_item_id, :tax_name, :tax_rate, :date_to, :date_from, :prorated_taxable_amount, :is_partial_tax_applied, :is_non_compliance_tax, :taxable_amount, :tax_amount, :tax_juris_type, :tax_juris_name, :tax_juris_code, :tax_amount_in_local_currency, :local_currency_code
18 | end
19 |
20 | class LineItemCredit < Model
21 | attr_accessor :cn_id, :applied_amount, :line_item_id
22 | end
23 |
24 | class LineItemAddress < Model
25 | attr_accessor :line_item_id, :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip, :validation_status
26 | end
27 |
28 | class Discount < Model
29 | attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
30 | end
31 |
32 | class Tax < Model
33 | attr_accessor :name, :amount, :description
34 | end
35 |
36 | attr_accessor :recurring, :price_type, :currency_code, :sub_total, :total, :credits_applied,
37 | :amount_paid, :amount_due, :line_items, :line_item_tiers, :line_item_discounts, :line_item_taxes,
38 | :line_item_credits, :line_item_addresses, :discounts, :taxes, :round_off_amount, :customer_id
39 |
40 | # OPERATIONS
41 | #-----------
42 |
43 | end # ~InvoiceEstimate
44 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/item.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Item < Model
3 |
4 | class ApplicableItem < Model
5 | attr_accessor :id
6 | end
7 |
8 | class BundleItem < Model
9 | attr_accessor :item_id, :item_type, :quantity, :price_allocation
10 | end
11 |
12 | class BundleConfiguration < Model
13 | attr_accessor :type
14 | end
15 |
16 | attr_accessor :id, :name, :external_name, :description, :status, :resource_version, :updated_at,
17 | :item_family_id, :type, :is_shippable, :is_giftable, :redirect_url, :enabled_for_checkout, :enabled_in_portal,
18 | :included_in_mrr, :item_applicability, :gift_claim_redirect_url, :unit, :metered, :usage_calculation,
19 | :is_percentage_pricing, :archived_at, :channel, :applicable_items, :bundle_items, :bundle_configuration,
20 | :metadata, :deleted, :business_entity_id
21 |
22 | # OPERATIONS
23 | #-----------
24 |
25 | def self.create(params, env=nil, headers={})
26 | jsonKeys = {
27 | :metadata => 0,
28 | }
29 | options = {
30 | :isIdempotent => true
31 | }
32 | Request.send('post', uri_path("items"), params, env, headers,nil, false, jsonKeys, options)
33 | end
34 |
35 | def self.retrieve(id, env=nil, headers={})
36 | jsonKeys = {
37 | }
38 | options = {}
39 | Request.send('get', uri_path("items",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
40 | end
41 |
42 | def self.update(id, params={}, env=nil, headers={})
43 | jsonKeys = {
44 | :metadata => 0,
45 | }
46 | options = {
47 | :isIdempotent => true
48 | }
49 | Request.send('post', uri_path("items",id.to_s), params, env, headers,nil, false, jsonKeys, options)
50 | end
51 |
52 | def self.list(params={}, env=nil, headers={})
53 | jsonKeys = {
54 | }
55 | options = {}
56 | Request.send_list_request('get', uri_path("items"), params, env, headers,nil, false, jsonKeys, options)
57 | end
58 |
59 | def self.delete(id, env=nil, headers={})
60 | jsonKeys = {
61 | }
62 | options = {
63 | :isIdempotent => true
64 | }
65 | Request.send('post', uri_path("items",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
66 | end
67 |
68 | end # ~Item
69 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/item_entitlement.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ItemEntitlement < Model
3 |
4 | attr_accessor :id, :item_id, :item_type, :feature_id, :feature_name, :value, :name
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.item_entitlements_for_item(id, params={}, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {}
13 | Request.send('get', uri_path("items",id.to_s,"item_entitlements"), params, env, headers,nil, false, jsonKeys, options)
14 | end
15 |
16 | def self.item_entitlements_for_feature(id, params={}, env=nil, headers={})
17 | jsonKeys = {
18 | }
19 | options = {}
20 | Request.send('get', uri_path("features",id.to_s,"item_entitlements"), params, env, headers,nil, false, jsonKeys, options)
21 | end
22 |
23 | def self.add_item_entitlements(id, params, env=nil, headers={})
24 | jsonKeys = {
25 | }
26 | options = {
27 | :isIdempotent => true
28 | }
29 | Request.send('post', uri_path("features",id.to_s,"item_entitlements"), params, env, headers,nil, false, jsonKeys, options)
30 | end
31 |
32 | def self.upsert_or_remove_item_entitlements_for_item(id, params, env=nil, headers={})
33 | jsonKeys = {
34 | }
35 | options = {
36 | :isIdempotent => true
37 | }
38 | Request.send('post', uri_path("items",id.to_s,"item_entitlements"), params, env, headers,nil, false, jsonKeys, options)
39 | end
40 |
41 | end # ~ItemEntitlement
42 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/item_family.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ItemFamily < Model
3 |
4 | attr_accessor :id, :name, :description, :status, :resource_version, :updated_at, :channel, :business_entity_id,
5 | :deleted
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.create(params, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {
14 | :isIdempotent => true
15 | }
16 | Request.send('post', uri_path("item_families"), params, env, headers,nil, false, jsonKeys, options)
17 | end
18 |
19 | def self.retrieve(id, env=nil, headers={})
20 | jsonKeys = {
21 | }
22 | options = {}
23 | Request.send('get', uri_path("item_families",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
24 | end
25 |
26 | def self.list(params={}, env=nil, headers={})
27 | jsonKeys = {
28 | }
29 | options = {}
30 | Request.send_list_request('get', uri_path("item_families"), params, env, headers,nil, false, jsonKeys, options)
31 | end
32 |
33 | def self.update(id, params={}, env=nil, headers={})
34 | jsonKeys = {
35 | }
36 | options = {
37 | :isIdempotent => true
38 | }
39 | Request.send('post', uri_path("item_families",id.to_s), params, env, headers,nil, false, jsonKeys, options)
40 | end
41 |
42 | def self.delete(id, env=nil, headers={})
43 | jsonKeys = {
44 | }
45 | options = {
46 | :isIdempotent => true
47 | }
48 | Request.send('post', uri_path("item_families",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
49 | end
50 |
51 | end # ~ItemFamily
52 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/item_price.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ItemPrice < Model
3 |
4 | class Tier < Model
5 | attr_accessor :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :pricing_type, :package_size
6 | end
7 |
8 | class TaxDetail < Model
9 | attr_accessor :tax_profile_id, :avalara_sale_type, :avalara_transaction_type, :avalara_service_type, :avalara_tax_code, :hsn_code, :taxjar_product_code
10 | end
11 |
12 | class TaxProvidersField < Model
13 | attr_accessor :provider_name, :field_id, :field_value
14 | end
15 |
16 | class AccountingDetail < Model
17 | attr_accessor :sku, :accounting_code, :accounting_category1, :accounting_category2, :accounting_category3, :accounting_category4
18 | end
19 |
20 | attr_accessor :id, :name, :item_family_id, :item_id, :description, :status, :external_name,
21 | :price_variant_id, :proration_type, :pricing_model, :price, :price_in_decimal, :period, :currency_code,
22 | :period_unit, :trial_period, :trial_period_unit, :trial_end_action, :shipping_period, :shipping_period_unit,
23 | :billing_cycles, :free_quantity, :free_quantity_in_decimal, :channel, :resource_version, :updated_at,
24 | :created_at, :usage_accumulation_reset_frequency, :archived_at, :invoice_notes, :tiers, :is_taxable,
25 | :tax_detail, :tax_providers_fields, :accounting_detail, :metadata, :item_type, :archivable,
26 | :parent_item_id, :show_description_in_invoices, :show_description_in_quotes, :deleted, :business_entity_id
27 |
28 | # OPERATIONS
29 | #-----------
30 |
31 | def self.create(params, env=nil, headers={})
32 | jsonKeys = {
33 | :metadata => 0,
34 | }
35 | options = {
36 | :isIdempotent => true
37 | }
38 | Request.send('post', uri_path("item_prices"), params, env, headers,nil, false, jsonKeys, options)
39 | end
40 |
41 | def self.retrieve(id, env=nil, headers={})
42 | jsonKeys = {
43 | }
44 | options = {}
45 | Request.send('get', uri_path("item_prices",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
46 | end
47 |
48 | def self.update(id, params, env=nil, headers={})
49 | jsonKeys = {
50 | :metadata => 0,
51 | }
52 | options = {
53 | :isIdempotent => true
54 | }
55 | Request.send('post', uri_path("item_prices",id.to_s), params, env, headers,nil, false, jsonKeys, options)
56 | end
57 |
58 | def self.list(params={}, env=nil, headers={})
59 | jsonKeys = {
60 | }
61 | options = {}
62 | Request.send_list_request('get', uri_path("item_prices"), params, env, headers,nil, false, jsonKeys, options)
63 | end
64 |
65 | def self.delete(id, env=nil, headers={})
66 | jsonKeys = {
67 | }
68 | options = {
69 | :isIdempotent => true
70 | }
71 | Request.send('post', uri_path("item_prices",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
72 | end
73 |
74 | def self.find_applicable_items(id, params={}, env=nil, headers={})
75 | jsonKeys = {
76 | }
77 | options = {}
78 | Request.send('get', uri_path("item_prices",id.to_s,"applicable_items"), params, env, headers,nil, false, jsonKeys, options)
79 | end
80 |
81 | def self.find_applicable_item_prices(id, params={}, env=nil, headers={})
82 | jsonKeys = {
83 | }
84 | options = {}
85 | Request.send('get', uri_path("item_prices",id.to_s,"applicable_item_prices"), params, env, headers,nil, false, jsonKeys, options)
86 | end
87 |
88 | end # ~ItemPrice
89 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/metadata.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Metadata < Model
3 |
4 | attr_accessor :change_type
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~Metadata
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/model.rb:
--------------------------------------------------------------------------------
1 | require 'uri'
2 | require 'cgi'
3 |
4 | module ChargeBee
5 | class Model
6 |
7 | def initialize(values, sub_types={}, dependant_types={})
8 | @values = values
9 | @sub_types = sub_types
10 | @dependant_types = dependant_types
11 | end
12 |
13 | def to_s(*args)
14 | JSON.pretty_generate(@values)
15 | end
16 |
17 | def inspect()
18 | "#<#{self.class}:0x#{self.object_id.to_s(16)} > JSON: " + JSON.pretty_generate(@values)
19 | end
20 |
21 | def load(values)
22 | instance_eval do
23 | values.each do |k, v|
24 | set_val = nil
25 | next if v.is_a?(Hash) && @dependant_types[k] != nil
26 |
27 | set_val = if v.is_a?(Hash)
28 | (@sub_types[k] != nil) ? @sub_types[k].construct(v) : v
29 | elsif v.is_a?(Array)
30 | if @sub_types[k] != nil
31 | v.map { |item| @sub_types[k].construct(item)}
32 | else
33 | v
34 | end
35 | else
36 | v
37 | end
38 |
39 | instance_variable_set("@#{replace_white_space_with_underscore(k)}", set_val)
40 | end
41 | end
42 | end
43 |
44 | def replace_white_space_with_underscore(s)
45 | s.to_s.tr(" ", "_")
46 | end
47 |
48 | def respond_to_missing?(m, include_private = false)
49 | @values.has_key?(m) || m[0,3] == "cf_" || super
50 | end
51 |
52 | def method_missing(m, *args, &block)
53 | if(@values.has_key?(m))
54 | return @values[m]
55 | elsif(m[0,3] == "cf_") # All the custom fields start with prefix cf_.
56 | return nil
57 | end
58 | message = "There's no method called #{m} #{args} here -- please try again."
59 | raise NoMethodError, message
60 | end
61 |
62 | def self.uri_path(*paths)
63 | url = ""
64 | for path in paths
65 | if(path.nil? || path.strip.length < 1)
66 | raise "Id is empty or nil"
67 | end
68 | url = "#{url}/#{CGI.escape(path.strip).gsub("+","%20").gsub("%2F", "/")}"
69 | end
70 | return url
71 | end
72 |
73 | def self.construct(values, sub_types = {}, dependant_types = {})
74 | if(values != nil)
75 | obj = self.new(values, sub_types, dependant_types)
76 | obj.load(values)
77 | obj
78 | end
79 | end
80 |
81 | def init_dependant(obj, type, sub_types = {})
82 | instance_eval do
83 | if(obj[type] != nil)
84 | case obj
85 | when Hash
86 | if(@dependant_types[type] != nil)
87 | dependant_obj = @dependant_types[type].construct(obj[type], sub_types)
88 | instance_variable_set("@#{type}", dependant_obj)
89 | end
90 | end
91 | end
92 | end
93 | end
94 |
95 | def init_dependant_list(obj, type, sub_types = {})
96 | instance_eval do
97 | if(obj[type] != nil)
98 | case obj[type]
99 | when Array
100 | if(@dependant_types[type] != nil)
101 | set_val = obj[type].map {|dt| @dependant_types[type].construct(dt, sub_types)}
102 | instance_variable_set("@#{type}", set_val)
103 | end
104 | end
105 | end
106 | end
107 | end
108 |
109 | end
110 | end
111 |
--------------------------------------------------------------------------------
/lib/chargebee/models/non_subscription.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class NonSubscription < Model
3 |
4 | attr_accessor :app_id, :invoice_id, :customer_id, :charge_id
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.process_receipt(id, params, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {
13 | :isIdempotent => true
14 | }
15 | Request.send('post', uri_path("non_subscriptions",id.to_s,"one_time_purchase"), params, env, headers,nil, false, jsonKeys, options)
16 | end
17 |
18 | end # ~NonSubscription
19 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/offer_event.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OfferEvent < Model
3 |
4 |
5 | # OPERATIONS
6 | #-----------
7 |
8 | def self.offer_events(params, env=nil, headers={})
9 | jsonKeys = {
10 | }
11 | options = {}
12 | Request.send('post', uri_path("offer_events"), params, env, headers, "grow", true, jsonKeys, options)
13 | end
14 |
15 | end # ~OfferEvent
16 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/offer_fulfillment.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OfferFulfillment < Model
3 |
4 | class Error < Model
5 | attr_accessor :code, :message
6 | end
7 |
8 | attr_accessor :id, :personalized_offer_id, :option_id, :processing_type, :status, :redirect_url,
9 | :failed_at, :created_at, :completed_at, :error
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | def self.offer_fulfillments(params, env=nil, headers={})
15 | jsonKeys = {
16 | }
17 | options = {}
18 | Request.send('post', uri_path("offer_fulfillments"), params, env, headers, "grow", true, jsonKeys, options)
19 | end
20 |
21 | def self.offer_fulfillments_get(id, env=nil, headers={})
22 | jsonKeys = {
23 | }
24 | options = {}
25 | Request.send('get', uri_path("offer_fulfillments",id.to_s), {}, env, headers, "grow", true, jsonKeys, options)
26 | end
27 |
28 | def self.offer_fulfillments_update(id, params, env=nil, headers={})
29 | jsonKeys = {
30 | }
31 | options = {}
32 | Request.send('post', uri_path("offer_fulfillments",id.to_s), params, env, headers, "grow", true, jsonKeys, options)
33 | end
34 |
35 | end # ~OfferFulfillment
36 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/omnichannel_one_time_order.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OmnichannelOneTimeOrder < Model
3 |
4 | attr_accessor :id, :app_id, :customer_id, :id_at_source, :origin, :source, :created_at, :resource_version,
5 | :omnichannel_one_time_order_items, :purchase_transaction
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.retrieve(id, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {}
14 | Request.send('get', uri_path("omnichannel_one_time_orders",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
15 | end
16 |
17 | def self.list(params={}, env=nil, headers={})
18 | jsonKeys = {
19 | }
20 | options = {}
21 | Request.send_list_request('get', uri_path("omnichannel_one_time_orders"), params, env, headers,nil, false, jsonKeys, options)
22 | end
23 |
24 | end # ~OmnichannelOneTimeOrder
25 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/omnichannel_one_time_order_item.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OmnichannelOneTimeOrderItem < Model
3 |
4 | attr_accessor :id, :item_id_at_source, :item_type_at_source, :quantity, :cancelled_at, :cancellation_reason,
5 | :created_at, :resource_version
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | end # ~OmnichannelOneTimeOrderItem
11 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/omnichannel_subscription.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OmnichannelSubscription < Model
3 |
4 | attr_accessor :id, :id_at_source, :app_id, :source, :customer_id, :created_at, :resource_version,
5 | :omnichannel_subscription_items, :initial_purchase_transaction
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.retrieve(id, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {}
14 | Request.send('get', uri_path("omnichannel_subscriptions",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
15 | end
16 |
17 | def self.list(params={}, env=nil, headers={})
18 | jsonKeys = {
19 | }
20 | options = {}
21 | Request.send_list_request('get', uri_path("omnichannel_subscriptions"), params, env, headers,nil, false, jsonKeys, options)
22 | end
23 |
24 | def self.omnichannel_transactions_for_omnichannel_subscription(id, params={}, env=nil, headers={})
25 | jsonKeys = {
26 | }
27 | options = {}
28 | Request.send('get', uri_path("omnichannel_subscriptions",id.to_s,"omnichannel_transactions"), params, env, headers,nil, false, jsonKeys, options)
29 | end
30 |
31 | def self.move(id, params, env=nil, headers={})
32 | jsonKeys = {
33 | }
34 | options = {
35 | :isIdempotent => true
36 | }
37 | Request.send('post', uri_path("omnichannel_subscriptions",id.to_s,"move"), params, env, headers,nil, false, jsonKeys, options)
38 | end
39 |
40 | end # ~OmnichannelSubscription
41 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/omnichannel_subscription_item.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OmnichannelSubscriptionItem < Model
3 |
4 | class UpcomingRenewal < Model
5 | attr_accessor :price_currency, :price_units, :price_nanos
6 | end
7 |
8 | class LinkedItem < Model
9 | attr_accessor :id, :linked_at
10 | end
11 |
12 | attr_accessor :id, :item_id_at_source, :item_parent_id_at_source, :status, :auto_renew_status,
13 | :current_term_start, :current_term_end, :expired_at, :expiration_reason, :cancelled_at, :cancellation_reason,
14 | :grace_period_expires_at, :resumes_at, :has_scheduled_changes, :resource_version, :omnichannel_subscription_item_offers,
15 | :upcoming_renewal, :linked_item
16 |
17 | # OPERATIONS
18 | #-----------
19 |
20 | def self.list_omni_sub_item_schedule_changes(id, params={}, env=nil, headers={})
21 | jsonKeys = {
22 | }
23 | options = {}
24 | Request.send('get', uri_path("omnichannel_subscription_items",id.to_s,"scheduled_changes"), params, env, headers,nil, false, jsonKeys, options)
25 | end
26 |
27 | end # ~OmnichannelSubscriptionItem
28 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/omnichannel_subscription_item_offer.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OmnichannelSubscriptionItemOffer < Model
3 |
4 | attr_accessor :id, :offer_id_at_source, :category, :category_at_source, :type, :type_at_source,
5 | :discount_type, :duration, :percentage, :price_currency, :price_units, :price_nanos, :offer_term_start,
6 | :offer_term_end, :resource_version
7 |
8 | # OPERATIONS
9 | #-----------
10 |
11 | end # ~OmnichannelSubscriptionItemOffer
12 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/omnichannel_subscription_item_scheduled_change.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OmnichannelSubscriptionItemScheduledChange < Model
3 |
4 | class CurrentState < Model
5 | attr_accessor :item_id_at_source
6 | end
7 |
8 | class ScheduledState < Model
9 | attr_accessor :item_id_at_source
10 | end
11 |
12 | attr_accessor :id, :omnichannel_subscription_item_id, :scheduled_at, :change_type, :created_at,
13 | :modified_at, :resource_version, :current_state, :scheduled_state
14 |
15 | # OPERATIONS
16 | #-----------
17 |
18 | end # ~OmnichannelSubscriptionItemScheduledChange
19 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/omnichannel_transaction.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class OmnichannelTransaction < Model
3 |
4 | class LinkedOmnichannelSubscription < Model
5 | attr_accessor :omnichannel_subscription_id
6 | end
7 |
8 | class LinkedOmnichannelOneTimeOrder < Model
9 | attr_accessor :omnichannel_one_time_order_id
10 | end
11 |
12 | attr_accessor :id, :id_at_source, :app_id, :price_currency, :price_units, :price_nanos, :type,
13 | :transacted_at, :created_at, :resource_version, :linked_omnichannel_subscriptions, :linked_omnichannel_one_time_orders
14 |
15 | # OPERATIONS
16 | #-----------
17 |
18 | end # ~OmnichannelTransaction
19 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/order.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Order < Model
3 |
4 | class OrderLineItem < Model
5 | attr_accessor :id, :invoice_id, :invoice_line_item_id, :unit_price, :description, :amount, :fulfillment_quantity, :fulfillment_amount, :tax_amount, :amount_paid, :amount_adjusted, :refundable_credits_issued, :refundable_credits, :is_shippable, :sku, :status, :entity_type, :item_level_discount_amount, :discount_amount, :entity_id
6 | end
7 |
8 | class ShippingAddress < Model
9 | attr_accessor :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip, :validation_status
10 | end
11 |
12 | class BillingAddress < Model
13 | attr_accessor :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip, :validation_status
14 | end
15 |
16 | class LineItemTax < Model
17 | attr_accessor :line_item_id, :tax_name, :tax_rate, :date_to, :date_from, :prorated_taxable_amount, :is_partial_tax_applied, :is_non_compliance_tax, :taxable_amount, :tax_amount, :tax_juris_type, :tax_juris_name, :tax_juris_code, :tax_amount_in_local_currency, :local_currency_code
18 | end
19 |
20 | class LineItemDiscount < Model
21 | attr_accessor :line_item_id, :discount_type, :coupon_id, :entity_id, :discount_amount
22 | end
23 |
24 | class LinkedCreditNote < Model
25 | attr_accessor :amount, :type, :id, :status, :amount_adjusted, :amount_refunded
26 | end
27 |
28 | class ResentOrder < Model
29 | attr_accessor :order_id, :reason, :amount
30 | end
31 |
32 | attr_accessor :id, :document_number, :invoice_id, :subscription_id, :customer_id, :status, :cancellation_reason,
33 | :payment_status, :order_type, :price_type, :reference_id, :fulfillment_status, :order_date,
34 | :shipping_date, :note, :tracking_id, :tracking_url, :batch_id, :created_by, :shipment_carrier,
35 | :invoice_round_off_amount, :tax, :amount_paid, :amount_adjusted, :refundable_credits_issued,
36 | :refundable_credits, :rounding_adjustement, :paid_on, :shipping_cut_off_date, :created_at, :status_update_at,
37 | :delivered_at, :shipped_at, :resource_version, :updated_at, :cancelled_at, :resent_status, :is_resent,
38 | :original_order_id, :order_line_items, :shipping_address, :billing_address, :discount, :sub_total,
39 | :total, :line_item_taxes, :line_item_discounts, :linked_credit_notes, :deleted, :currency_code,
40 | :is_gifted, :gift_note, :gift_id, :resend_reason, :resent_orders, :business_entity_id
41 |
42 | # OPERATIONS
43 | #-----------
44 |
45 | def self.create(params, env=nil, headers={})
46 | jsonKeys = {
47 | }
48 | options = {
49 | :isIdempotent => true
50 | }
51 | Request.send('post', uri_path("orders"), params, env, headers,nil, false, jsonKeys, options)
52 | end
53 |
54 | def self.update(id, params={}, env=nil, headers={})
55 | jsonKeys = {
56 | }
57 | options = {
58 | :isIdempotent => true
59 | }
60 | Request.send('post', uri_path("orders",id.to_s), params, env, headers,nil, false, jsonKeys, options)
61 | end
62 |
63 | def self.import_order(params, env=nil, headers={})
64 | jsonKeys = {
65 | }
66 | options = {
67 | :isIdempotent => true
68 | }
69 | Request.send('post', uri_path("orders","import_order"), params, env, headers,nil, false, jsonKeys, options)
70 | end
71 |
72 | def self.assign_order_number(id, env=nil, headers={})
73 | jsonKeys = {
74 | }
75 | options = {
76 | :isIdempotent => true
77 | }
78 | Request.send('post', uri_path("orders",id.to_s,"assign_order_number"), {}, env, headers,nil, false, jsonKeys, options)
79 | end
80 |
81 | def self.cancel(id, params, env=nil, headers={})
82 | jsonKeys = {
83 | }
84 | options = {
85 | :isIdempotent => true
86 | }
87 | Request.send('post', uri_path("orders",id.to_s,"cancel"), params, env, headers,nil, false, jsonKeys, options)
88 | end
89 |
90 | def self.create_refundable_credit_note(id, params, env=nil, headers={})
91 | jsonKeys = {
92 | }
93 | options = {
94 | :isIdempotent => true
95 | }
96 | Request.send('post', uri_path("orders",id.to_s,"create_refundable_credit_note"), params, env, headers,nil, false, jsonKeys, options)
97 | end
98 |
99 | def self.reopen(id, params={}, env=nil, headers={})
100 | jsonKeys = {
101 | }
102 | options = {
103 | :isIdempotent => true
104 | }
105 | Request.send('post', uri_path("orders",id.to_s,"reopen"), params, env, headers,nil, false, jsonKeys, options)
106 | end
107 |
108 | def self.retrieve(id, env=nil, headers={})
109 | jsonKeys = {
110 | }
111 | options = {}
112 | Request.send('get', uri_path("orders",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
113 | end
114 |
115 | def self.delete(id, env=nil, headers={})
116 | jsonKeys = {
117 | }
118 | options = {
119 | :isIdempotent => true
120 | }
121 | Request.send('post', uri_path("orders",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
122 | end
123 |
124 | def self.list(params={}, env=nil, headers={})
125 | jsonKeys = {
126 | }
127 | options = {}
128 | Request.send_list_request('get', uri_path("orders"), params, env, headers,nil, false, jsonKeys, options)
129 | end
130 |
131 | def self.orders_for_invoice(id, params={}, env=nil, headers={})
132 | jsonKeys = {
133 | }
134 | options = {}
135 | Request.send('get', uri_path("invoices",id.to_s,"orders"), params, env, headers,nil, false, jsonKeys, options)
136 | end
137 |
138 | def self.resend(id, params={}, env=nil, headers={})
139 | jsonKeys = {
140 | }
141 | options = {
142 | :isIdempotent => true
143 | }
144 | Request.send('post', uri_path("orders",id.to_s,"resend"), params, env, headers,nil, false, jsonKeys, options)
145 | end
146 |
147 | end # ~Order
148 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/payment_intent.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PaymentIntent < Model
3 |
4 | class PaymentAttempt < Model
5 | attr_accessor :id, :status, :payment_method_type, :id_at_gateway, :error_code, :error_text, :checkout_details, :created_at, :modified_at, :error_detail
6 | end
7 |
8 | class PaymentAttempt < Model
9 | attr_accessor :id, :status, :payment_method_type, :id_at_gateway, :error_code, :error_text, :checkout_details, :created_at, :modified_at, :error_detail
10 | end
11 |
12 | attr_accessor :id, :status, :currency_code, :amount, :gateway_account_id, :expires_at, :reference_id,
13 | :payment_method_type, :success_url, :failure_url, :created_at, :modified_at, :resource_version,
14 | :updated_at, :customer_id, :gateway, :active_payment_attempt, :payment_attempts, :business_entity_id
15 |
16 | # OPERATIONS
17 | #-----------
18 |
19 | def self.create(params, env=nil, headers={})
20 | jsonKeys = {
21 | }
22 | options = {
23 | :isIdempotent => true
24 | }
25 | Request.send('post', uri_path("payment_intents"), params, env, headers,nil, false, jsonKeys, options)
26 | end
27 |
28 | def self.update(id, params={}, env=nil, headers={})
29 | jsonKeys = {
30 | }
31 | options = {
32 | :isIdempotent => true
33 | }
34 | Request.send('post', uri_path("payment_intents",id.to_s), params, env, headers,nil, false, jsonKeys, options)
35 | end
36 |
37 | def self.retrieve(id, env=nil, headers={})
38 | jsonKeys = {
39 | }
40 | options = {}
41 | Request.send('get', uri_path("payment_intents",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
42 | end
43 |
44 | end # ~PaymentIntent
45 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/payment_reference_number.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PaymentReferenceNumber < Model
3 |
4 | attr_accessor :id, :type, :number, :invoice_id
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~PaymentReferenceNumber
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/payment_schedule.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PaymentSchedule < Model
3 |
4 | class ScheduleEntry < Model
5 | attr_accessor :id, :date, :amount, :status
6 | end
7 |
8 | attr_accessor :id, :scheme_id, :entity_type, :entity_id, :amount, :created_at, :resource_version,
9 | :updated_at, :currency_code, :schedule_entries
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | end # ~PaymentSchedule
15 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/payment_schedule_estimate.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PaymentScheduleEstimate < Model
3 |
4 | class ScheduleEntry < Model
5 | attr_accessor :id, :date, :amount, :status
6 | end
7 |
8 | attr_accessor :id, :scheme_id, :entity_type, :entity_id, :amount, :currency_code, :schedule_entries
9 |
10 | # OPERATIONS
11 | #-----------
12 |
13 | end # ~PaymentScheduleEstimate
14 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/payment_schedule_scheme.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PaymentScheduleScheme < Model
3 |
4 | class PreferredSchedule < Model
5 | attr_accessor :period, :amount_percentage
6 | end
7 |
8 | attr_accessor :id, :name, :description, :number_of_schedules, :period_unit, :period, :created_at,
9 | :resource_version, :updated_at, :preferred_schedules
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | def self.create(params, env=nil, headers={})
15 | jsonKeys = {
16 | }
17 | options = {
18 | :isIdempotent => true
19 | }
20 | Request.send('post', uri_path("payment_schedule_schemes"), params, env, headers,nil, false, jsonKeys, options)
21 | end
22 |
23 | def self.retrieve(id, env=nil, headers={})
24 | jsonKeys = {
25 | }
26 | options = {}
27 | Request.send('get', uri_path("payment_schedule_schemes",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
28 | end
29 |
30 | def self.delete(id, env=nil, headers={})
31 | jsonKeys = {
32 | }
33 | options = {
34 | :isIdempotent => true
35 | }
36 | Request.send('post', uri_path("payment_schedule_schemes",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
37 | end
38 |
39 | end # ~PaymentScheduleScheme
40 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/payment_source.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PaymentSource < Model
3 |
4 | class Card < Model
5 | attr_accessor :first_name, :last_name, :iin, :last4, :brand, :funding_type, :expiry_month, :expiry_year, :billing_addr1, :billing_addr2, :billing_city, :billing_state_code, :billing_state, :billing_country, :billing_zip, :masked_number
6 | end
7 |
8 | class BankAccount < Model
9 | attr_accessor :last4, :name_on_account, :first_name, :last_name, :direct_debit_scheme, :bank_name, :mandate_id, :account_type, :echeck_type, :account_holder_type, :email
10 | end
11 |
12 | class CustVoucherSource < Model
13 | attr_accessor :last4, :first_name, :last_name, :email
14 | end
15 |
16 | class BillingAddress < Model
17 | attr_accessor :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip, :validation_status
18 | end
19 |
20 | class AmazonPayment < Model
21 | attr_accessor :email, :agreement_id
22 | end
23 |
24 | class Upi < Model
25 | attr_accessor :vpa
26 | end
27 |
28 | class Paypal < Model
29 | attr_accessor :email, :agreement_id
30 | end
31 |
32 | class Venmo < Model
33 | attr_accessor :user_name
34 | end
35 |
36 | class KlarnaPayNow < Model
37 | attr_accessor :email
38 | end
39 |
40 | class Mandate < Model
41 | attr_accessor :id, :subscription_id, :created_at
42 | end
43 |
44 | attr_accessor :id, :resource_version, :updated_at, :created_at, :customer_id, :type, :reference_id,
45 | :status, :gateway, :gateway_account_id, :ip_address, :issuing_country, :card, :bank_account,
46 | :boleto, :billing_address, :amazon_payment, :upi, :paypal, :venmo, :klarna_pay_now, :mandates,
47 | :deleted, :business_entity_id
48 |
49 | # OPERATIONS
50 | #-----------
51 |
52 | def self.create_using_temp_token(params, env=nil, headers={})
53 | jsonKeys = {
54 | :additional_information => 0,
55 | }
56 | options = {
57 | :isIdempotent => true
58 | }
59 | Request.send('post', uri_path("payment_sources","create_using_temp_token"), params, env, headers,nil, false, jsonKeys, options)
60 | end
61 |
62 | def self.create_using_permanent_token(params, env=nil, headers={})
63 | jsonKeys = {
64 | :additional_information => 0,
65 | }
66 | options = {
67 | :isIdempotent => true
68 | }
69 | Request.send('post', uri_path("payment_sources","create_using_permanent_token"), params, env, headers,nil, false, jsonKeys, options)
70 | end
71 |
72 | def self.create_using_token(params, env=nil, headers={})
73 | jsonKeys = {
74 | }
75 | options = {
76 | :isIdempotent => true
77 | }
78 | Request.send('post', uri_path("payment_sources","create_using_token"), params, env, headers,nil, false, jsonKeys, options)
79 | end
80 |
81 | def self.create_using_payment_intent(params, env=nil, headers={})
82 | jsonKeys = {
83 | :additional_info => 1,
84 | :additional_information => 1,
85 | }
86 | options = {
87 | :isIdempotent => true
88 | }
89 | Request.send('post', uri_path("payment_sources","create_using_payment_intent"), params, env, headers,nil, false, jsonKeys, options)
90 | end
91 |
92 | def self.create_voucher_payment_source(params, env=nil, headers={})
93 | jsonKeys = {
94 | :billing_address => 1,
95 | }
96 | options = {
97 | :isIdempotent => true
98 | }
99 | Request.send('post', uri_path("payment_sources","create_voucher_payment_source"), params, env, headers,nil, false, jsonKeys, options)
100 | end
101 |
102 | def self.create_card(params, env=nil, headers={})
103 | jsonKeys = {
104 | :additional_information => 1,
105 | }
106 | options = {
107 | :isIdempotent => true
108 | }
109 | Request.send('post', uri_path("payment_sources","create_card"), params, env, headers,nil, false, jsonKeys, options)
110 | end
111 |
112 | def self.create_bank_account(params, env=nil, headers={})
113 | jsonKeys = {
114 | :billing_address => 1,
115 | }
116 | options = {
117 | :isIdempotent => true
118 | }
119 | Request.send('post', uri_path("payment_sources","create_bank_account"), params, env, headers,nil, false, jsonKeys, options)
120 | end
121 |
122 | def self.update_card(id, params={}, env=nil, headers={})
123 | jsonKeys = {
124 | :gateway_meta_data => 0,
125 | :additional_information => 1,
126 | }
127 | options = {
128 | :isIdempotent => true
129 | }
130 | Request.send('post', uri_path("payment_sources",id.to_s,"update_card"), params, env, headers,nil, false, jsonKeys, options)
131 | end
132 |
133 | def self.update_bank_account(id, params={}, env=nil, headers={})
134 | jsonKeys = {
135 | }
136 | options = {
137 | :isIdempotent => true
138 | }
139 | Request.send('post', uri_path("payment_sources",id.to_s,"update_bank_account"), params, env, headers,nil, false, jsonKeys, options)
140 | end
141 |
142 | def self.verify_bank_account(id, params, env=nil, headers={})
143 | jsonKeys = {
144 | }
145 | options = {
146 | :isIdempotent => true
147 | }
148 | Request.send('post', uri_path("payment_sources",id.to_s,"verify_bank_account"), params, env, headers,nil, false, jsonKeys, options)
149 | end
150 |
151 | def self.retrieve(id, env=nil, headers={})
152 | jsonKeys = {
153 | }
154 | options = {}
155 | Request.send('get', uri_path("payment_sources",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
156 | end
157 |
158 | def self.list(params={}, env=nil, headers={})
159 | jsonKeys = {
160 | }
161 | options = {}
162 | Request.send_list_request('get', uri_path("payment_sources"), params, env, headers,nil, false, jsonKeys, options)
163 | end
164 |
165 | def self.switch_gateway_account(id, params, env=nil, headers={})
166 | jsonKeys = {
167 | }
168 | options = {
169 | :isIdempotent => true
170 | }
171 | Request.send('post', uri_path("payment_sources",id.to_s,"switch_gateway_account"), params, env, headers,nil, false, jsonKeys, options)
172 | end
173 |
174 | def self.export_payment_source(id, params, env=nil, headers={})
175 | jsonKeys = {
176 | }
177 | options = {
178 | :isIdempotent => true
179 | }
180 | Request.send('post', uri_path("payment_sources",id.to_s,"export_payment_source"), params, env, headers,nil, false, jsonKeys, options)
181 | end
182 |
183 | def self.delete(id, env=nil, headers={})
184 | jsonKeys = {
185 | }
186 | options = {
187 | :isIdempotent => true
188 | }
189 | Request.send('post', uri_path("payment_sources",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
190 | end
191 |
192 | def self.delete_local(id, env=nil, headers={})
193 | jsonKeys = {
194 | }
195 | options = {
196 | :isIdempotent => true
197 | }
198 | Request.send('post', uri_path("payment_sources",id.to_s,"delete_local"), {}, env, headers,nil, false, jsonKeys, options)
199 | end
200 |
201 | end # ~PaymentSource
202 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/payment_voucher.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PaymentVoucher < Model
3 |
4 | class LinkedInvoice < Model
5 | attr_accessor :invoice_id, :txn_id, :applied_at
6 | end
7 |
8 | attr_accessor :id, :id_at_gateway, :payment_voucher_type, :expires_at, :status, :subscription_id,
9 | :currency_code, :amount, :gateway_account_id, :payment_source_id, :gateway, :payload, :error_code,
10 | :error_text, :url, :date, :resource_version, :updated_at, :customer_id, :linked_invoices
11 |
12 | # OPERATIONS
13 | #-----------
14 |
15 | def self.create(params, env=nil, headers={})
16 | jsonKeys = {
17 | }
18 | options = {
19 | :isIdempotent => true
20 | }
21 | Request.send('post', uri_path("payment_vouchers"), params, env, headers,nil, false, jsonKeys, options)
22 | end
23 |
24 | def self.retrieve(id, env=nil, headers={})
25 | jsonKeys = {
26 | }
27 | options = {}
28 | Request.send('get', uri_path("payment_vouchers",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
29 | end
30 |
31 | def self.payment_vouchers_for_invoice(id, params={}, env=nil, headers={})
32 | jsonKeys = {
33 | }
34 | options = {}
35 | Request.send('get', uri_path("invoices",id.to_s,"payment_vouchers"), params, env, headers,nil, false, jsonKeys, options)
36 | end
37 |
38 | def self.payment_vouchers_for_customer(id, params={}, env=nil, headers={})
39 | jsonKeys = {
40 | }
41 | options = {}
42 | Request.send('get', uri_path("customers",id.to_s,"payment_vouchers"), params, env, headers,nil, false, jsonKeys, options)
43 | end
44 |
45 | end # ~PaymentVoucher
46 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/personalized_offer.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PersonalizedOffer < Model
3 |
4 | class Content < Model
5 | attr_accessor :title, :description
6 | end
7 |
8 | class Option < Model
9 | attr_accessor :id, :label, :processing_type, :processing_layout, :redirect_url
10 | end
11 |
12 | attr_accessor :id, :offer_id, :content, :options
13 |
14 | # OPERATIONS
15 | #-----------
16 |
17 | def self.personalized_offers(params, env=nil, headers={})
18 | jsonKeys = {
19 | :custom => 0,
20 | }
21 | options = {}
22 | Request.send('post', uri_path("personalized_offers"), params, env, headers, "grow", true, jsonKeys, options)
23 | end
24 |
25 | end # ~PersonalizedOffer
26 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/plan.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Plan < Model
3 |
4 | class Tier < Model
5 | attr_accessor :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :pricing_type, :package_size
6 | end
7 |
8 | class TaxProvidersField < Model
9 | attr_accessor :provider_name, :field_id, :field_value
10 | end
11 |
12 | class ApplicableAddon < Model
13 | attr_accessor :id
14 | end
15 |
16 | class AttachedAddon < Model
17 | attr_accessor :id, :quantity, :billing_cycles, :type, :quantity_in_decimal
18 | end
19 |
20 | class EventBasedAddon < Model
21 | attr_accessor :id, :quantity, :on_event, :charge_once, :quantity_in_decimal
22 | end
23 |
24 | attr_accessor :id, :name, :invoice_name, :description, :price, :currency_code, :period, :period_unit,
25 | :trial_period, :trial_period_unit, :trial_end_action, :pricing_model, :charge_model, :free_quantity,
26 | :setup_cost, :downgrade_penalty, :status, :archived_at, :billing_cycles, :redirect_url, :enabled_in_hosted_pages,
27 | :enabled_in_portal, :addon_applicability, :tax_code, :hsn_code, :taxjar_product_code, :avalara_sale_type,
28 | :avalara_transaction_type, :avalara_service_type, :sku, :accounting_code, :accounting_category1,
29 | :accounting_category2, :accounting_category3, :accounting_category4, :is_shippable, :shipping_frequency_period,
30 | :shipping_frequency_period_unit, :resource_version, :updated_at, :giftable, :claim_url, :free_quantity_in_decimal,
31 | :price_in_decimal, :channel, :invoice_notes, :taxable, :tax_profile_id, :meta_data, :tiers,
32 | :tax_providers_fields, :applicable_addons, :attached_addons, :event_based_addons, :show_description_in_invoices,
33 | :show_description_in_quotes
34 |
35 | # OPERATIONS
36 | #-----------
37 |
38 | def self.create(params, env=nil, headers={})
39 | jsonKeys = {
40 | :meta_data => 0,
41 | }
42 | options = {
43 | :isIdempotent => true
44 | }
45 | Request.send('post', uri_path("plans"), params, env, headers,nil, false, jsonKeys, options)
46 | end
47 |
48 | def self.update(id, params, env=nil, headers={})
49 | jsonKeys = {
50 | :meta_data => 0,
51 | }
52 | options = {
53 | :isIdempotent => true
54 | }
55 | Request.send('post', uri_path("plans",id.to_s), params, env, headers,nil, false, jsonKeys, options)
56 | end
57 |
58 | def self.list(params={}, env=nil, headers={})
59 | jsonKeys = {
60 | }
61 | options = {}
62 | Request.send_list_request('get', uri_path("plans"), params, env, headers,nil, false, jsonKeys, options)
63 | end
64 |
65 | def self.retrieve(id, env=nil, headers={})
66 | jsonKeys = {
67 | }
68 | options = {}
69 | Request.send('get', uri_path("plans",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
70 | end
71 |
72 | def self.delete(id, env=nil, headers={})
73 | jsonKeys = {
74 | }
75 | options = {
76 | :isIdempotent => true
77 | }
78 | Request.send('post', uri_path("plans",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
79 | end
80 |
81 | def self.copy(params, env=nil, headers={})
82 | jsonKeys = {
83 | }
84 | options = {
85 | :isIdempotent => true
86 | }
87 | Request.send('post', uri_path("plans","copy"), params, env, headers,nil, false, jsonKeys, options)
88 | end
89 |
90 | def self.unarchive(id, env=nil, headers={})
91 | jsonKeys = {
92 | }
93 | options = {
94 | :isIdempotent => true
95 | }
96 | Request.send('post', uri_path("plans",id.to_s,"unarchive"), {}, env, headers,nil, false, jsonKeys, options)
97 | end
98 |
99 | end # ~Plan
100 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/portal_session.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PortalSession < Model
3 |
4 | class LinkedCustomer < Model
5 | attr_accessor :customer_id, :email, :has_billing_address, :has_payment_method, :has_active_subscription
6 | end
7 |
8 | attr_accessor :id, :token, :access_url, :redirect_url, :status, :created_at, :expires_at, :customer_id,
9 | :login_at, :logout_at, :login_ipaddress, :logout_ipaddress, :linked_customers
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | def self.create(params, env=nil, headers={})
15 | jsonKeys = {
16 | }
17 | options = {
18 | :isIdempotent => true
19 | }
20 | Request.send('post', uri_path("portal_sessions"), params, env, headers,nil, false, jsonKeys, options)
21 | end
22 |
23 | def self.retrieve(id, env=nil, headers={})
24 | jsonKeys = {
25 | }
26 | options = {}
27 | Request.send('get', uri_path("portal_sessions",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
28 | end
29 |
30 | def self.logout(id, env=nil, headers={})
31 | jsonKeys = {
32 | }
33 | options = {
34 | :isIdempotent => true
35 | }
36 | Request.send('post', uri_path("portal_sessions",id.to_s,"logout"), {}, env, headers,nil, false, jsonKeys, options)
37 | end
38 |
39 | def self.activate(id, params, env=nil, headers={})
40 | jsonKeys = {
41 | }
42 | options = {
43 | :isIdempotent => true
44 | }
45 | Request.send('post', uri_path("portal_sessions",id.to_s,"activate"), params, env, headers,nil, false, jsonKeys, options)
46 | end
47 |
48 | end # ~PortalSession
49 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/price_variant.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PriceVariant < Model
3 |
4 | class Attribute < Model
5 | attr_accessor :name, :value
6 | end
7 |
8 | attr_accessor :id, :name, :external_name, :variant_group, :description, :status, :created_at,
9 | :resource_version, :updated_at, :archived_at, :attributes, :business_entity_id, :deleted
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | def self.create(params, env=nil, headers={})
15 | jsonKeys = {
16 | }
17 | options = {
18 | :isIdempotent => true
19 | }
20 | Request.send('post', uri_path("price_variants"), params, env, headers,nil, false, jsonKeys, options)
21 | end
22 |
23 | def self.retrieve(id, env=nil, headers={})
24 | jsonKeys = {
25 | }
26 | options = {}
27 | Request.send('get', uri_path("price_variants",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
28 | end
29 |
30 | def self.update(id, params, env=nil, headers={})
31 | jsonKeys = {
32 | }
33 | options = {
34 | :isIdempotent => true
35 | }
36 | Request.send('post', uri_path("price_variants",id.to_s), params, env, headers,nil, false, jsonKeys, options)
37 | end
38 |
39 | def self.delete(id, env=nil, headers={})
40 | jsonKeys = {
41 | }
42 | options = {
43 | :isIdempotent => true
44 | }
45 | Request.send('post', uri_path("price_variants",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
46 | end
47 |
48 | def self.list(params={}, env=nil, headers={})
49 | jsonKeys = {
50 | }
51 | options = {}
52 | Request.send_list_request('get', uri_path("price_variants"), params, env, headers,nil, false, jsonKeys, options)
53 | end
54 |
55 | end # ~PriceVariant
56 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/pricing_page_session.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PricingPageSession < Model
3 |
4 | attr_accessor :id, :url, :created_at, :expires_at
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.create_for_new_subscription(params, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {
13 | :isIdempotent => true
14 | }
15 | Request.send('post', uri_path("pricing_page_sessions","create_for_new_subscription"), params, env, headers,nil, false, jsonKeys, options)
16 | end
17 |
18 | def self.create_for_existing_subscription(params, env=nil, headers={})
19 | jsonKeys = {
20 | }
21 | options = {
22 | :isIdempotent => true
23 | }
24 | Request.send('post', uri_path("pricing_page_sessions","create_for_existing_subscription"), params, env, headers,nil, false, jsonKeys, options)
25 | end
26 |
27 | end # ~PricingPageSession
28 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/promotional_credit.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class PromotionalCredit < Model
3 |
4 | attr_accessor :id, :customer_id, :type, :amount_in_decimal, :amount, :currency_code, :description,
5 | :credit_type, :reference, :closing_balance, :done_by, :created_at, :business_entity_id
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.add(params, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {
14 | :isIdempotent => true
15 | }
16 | Request.send('post', uri_path("promotional_credits","add"), params, env, headers,nil, false, jsonKeys, options)
17 | end
18 |
19 | def self.deduct(params, env=nil, headers={})
20 | jsonKeys = {
21 | }
22 | options = {
23 | :isIdempotent => true
24 | }
25 | Request.send('post', uri_path("promotional_credits","deduct"), params, env, headers,nil, false, jsonKeys, options)
26 | end
27 |
28 | def self.set(params, env=nil, headers={})
29 | jsonKeys = {
30 | }
31 | options = {
32 | :isIdempotent => true
33 | }
34 | Request.send('post', uri_path("promotional_credits","set"), params, env, headers,nil, false, jsonKeys, options)
35 | end
36 |
37 | def self.list(params={}, env=nil, headers={})
38 | jsonKeys = {
39 | }
40 | options = {}
41 | Request.send_list_request('get', uri_path("promotional_credits"), params, env, headers,nil, false, jsonKeys, options)
42 | end
43 |
44 | def self.retrieve(id, env=nil, headers={})
45 | jsonKeys = {
46 | }
47 | options = {}
48 | Request.send('get', uri_path("promotional_credits",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
49 | end
50 |
51 | end # ~PromotionalCredit
52 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/purchase.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Purchase < Model
3 |
4 | attr_accessor :id, :customer_id, :created_at, :modified_at, :subscription_ids, :invoice_ids
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.create(params, env=nil, headers={})
10 | jsonKeys = {
11 | :additional_information => 1,
12 | :meta_data => 1,
13 | }
14 | options = {
15 | :isIdempotent => true
16 | }
17 | Request.send('post', uri_path("purchases"), params, env, headers,nil, false, jsonKeys, options)
18 | end
19 |
20 | def self.estimate(params, env=nil, headers={})
21 | jsonKeys = {
22 | :exemption_details => 1,
23 | }
24 | options = {}
25 | Request.send('post', uri_path("purchases","estimate"), params, env, headers,nil, false, jsonKeys, options)
26 | end
27 |
28 | end # ~Purchase
29 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/quote_line_group.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class QuoteLineGroup < Model
3 |
4 | class LineItem < Model
5 | attr_accessor :id, :subscription_id, :date_from, :date_to, :unit_amount, :quantity, :amount, :pricing_model, :is_taxed, :tax_amount, :tax_rate, :unit_amount_in_decimal, :quantity_in_decimal, :amount_in_decimal, :discount_amount, :item_level_discount_amount, :metered, :is_percentage_pricing, :reference_line_item_id, :description, :entity_description, :entity_type, :tax_exempt_reason, :entity_id, :customer_id
6 | end
7 |
8 | class LineItemDiscount < Model
9 | attr_accessor :line_item_id, :discount_type, :coupon_id, :entity_id, :discount_amount
10 | end
11 |
12 | class LineItemTax < Model
13 | attr_accessor :line_item_id, :tax_name, :tax_rate, :date_to, :date_from, :prorated_taxable_amount, :is_partial_tax_applied, :is_non_compliance_tax, :taxable_amount, :tax_amount, :tax_juris_type, :tax_juris_name, :tax_juris_code, :tax_amount_in_local_currency, :local_currency_code
14 | end
15 |
16 | class Discount < Model
17 | attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
18 | end
19 |
20 | class Tax < Model
21 | attr_accessor :name, :amount, :description
22 | end
23 |
24 | attr_accessor :version, :id, :sub_total, :total, :credits_applied, :amount_paid, :amount_due,
25 | :charge_event, :billing_cycle_number, :line_items, :line_item_discounts, :line_item_taxes, :discounts,
26 | :taxes
27 |
28 | # OPERATIONS
29 | #-----------
30 |
31 | end # ~QuoteLineGroup
32 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/quoted_charge.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class QuotedCharge < Model
3 |
4 | class Charge < Model
5 | attr_accessor :amount, :amount_in_decimal, :description, :service_period_in_days, :avalara_sale_type, :avalara_transaction_type, :avalara_service_type
6 | end
7 |
8 | class Addon < Model
9 | attr_accessor :id, :quantity, :unit_price, :quantity_in_decimal, :unit_price_in_decimal, :proration_type, :service_period
10 | end
11 |
12 | class InvoiceItem < Model
13 | attr_accessor :item_price_id, :quantity, :quantity_in_decimal, :unit_price, :unit_price_in_decimal, :service_period_days
14 | end
15 |
16 | class ItemTier < Model
17 | attr_accessor :item_price_id, :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :pricing_type, :package_size, :index
18 | end
19 |
20 | class Coupon < Model
21 | attr_accessor :coupon_id
22 | end
23 |
24 | class CouponApplicabilityMapping < Model
25 | attr_accessor :coupon_id, :applicable_item_price_ids
26 | end
27 |
28 | attr_accessor :charges, :addons, :invoice_items, :item_tiers, :coupons, :coupon_applicability_mappings
29 |
30 | # OPERATIONS
31 | #-----------
32 |
33 | end # ~QuotedCharge
34 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/quoted_ramp.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class QuotedRamp < Model
3 |
4 | class LineItem < Model
5 | attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :metered_quantity, :unit_price, :unit_price_in_decimal, :amount, :amount_in_decimal, :billing_period, :billing_period_unit, :free_quantity, :free_quantity_in_decimal, :billing_cycles, :service_period_days, :charge_on_event, :charge_once, :charge_on_option, :start_date, :end_date, :ramp_tier_id, :discount_per_billing_cycle, :discount_per_billing_cycle_in_decimal, :item_level_discount_per_billing_cycle, :item_level_discount_per_billing_cycle_in_decimal, :amount_per_billing_cycle, :amount_per_billing_cycle_in_decimal, :net_amount_per_billing_cycle, :net_amount_per_billing_cycle_in_decimal
6 | end
7 |
8 | class Discount < Model
9 | attr_accessor :id, :invoice_name, :type, :percentage, :amount, :duration_type, :entity_type, :entity_id, :period, :period_unit, :included_in_mrr, :apply_on, :item_price_id, :created_at, :updated_at, :start_date, :end_date
10 | end
11 |
12 | class ItemTier < Model
13 | attr_accessor :item_price_id, :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :ramp_tier_id, :pricing_type, :package_size
14 | end
15 |
16 | class CouponApplicabilityMapping < Model
17 | attr_accessor :coupon_id, :applicable_item_price_ids
18 | end
19 |
20 | attr_accessor :id, :line_items, :discounts, :item_tiers, :coupon_applicability_mappings
21 |
22 | # OPERATIONS
23 | #-----------
24 |
25 | end # ~QuotedRamp
26 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/quoted_subscription.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class QuotedSubscription < Model
3 |
4 | class Addon < Model
5 | attr_accessor :id, :quantity, :unit_price, :amount, :trial_end, :remaining_billing_cycles, :quantity_in_decimal, :unit_price_in_decimal, :amount_in_decimal, :proration_type
6 | end
7 |
8 | class EventBasedAddon < Model
9 | attr_accessor :id, :quantity, :unit_price, :service_period_in_days, :on_event, :charge_once, :quantity_in_decimal, :unit_price_in_decimal
10 | end
11 |
12 | class Coupon < Model
13 | attr_accessor :coupon_id
14 | end
15 |
16 | class SubscriptionItem < Model
17 | attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :metered_quantity, :last_calculated_at, :unit_price, :unit_price_in_decimal, :amount, :current_term_start, :current_term_end, :next_billing_at, :amount_in_decimal, :billing_period, :billing_period_unit, :free_quantity, :free_quantity_in_decimal, :trial_end, :billing_cycles, :service_period_days, :charge_on_event, :charge_once, :charge_on_option, :proration_type, :usage_accumulation_reset_frequency
18 | end
19 |
20 | class ItemTier < Model
21 | attr_accessor :item_price_id, :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :pricing_type, :package_size, :index
22 | end
23 |
24 | class QuotedContractTerm < Model
25 | attr_accessor :contract_start, :contract_end, :billing_cycle, :action_at_term_end, :total_contract_value, :cancellation_cutoff_period
26 | end
27 |
28 | attr_accessor :id, :plan_id, :plan_quantity, :plan_unit_price, :setup_fee, :billing_period,
29 | :billing_period_unit, :start_date, :trial_end, :remaining_billing_cycles, :po_number, :auto_collection,
30 | :plan_quantity_in_decimal, :plan_unit_price_in_decimal, :changes_scheduled_at, :change_option,
31 | :contract_term_billing_cycle_on_renewal, :addons, :event_based_addons, :coupons, :subscription_items,
32 | :item_tiers, :quoted_contract_term
33 |
34 | # OPERATIONS
35 | #-----------
36 |
37 | end # ~QuotedSubscription
38 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/ramp.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Ramp < Model
3 |
4 | class ItemsToAdd < Model
5 | attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :unit_price, :unit_price_in_decimal, :amount, :amount_in_decimal, :free_quantity, :free_quantity_in_decimal, :billing_cycles, :service_period_days, :metered_quantity, :charge_once, :charge_on_option, :charge_on_event
6 | end
7 |
8 | class ItemsToUpdate < Model
9 | attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :unit_price, :unit_price_in_decimal, :amount, :amount_in_decimal, :free_quantity, :free_quantity_in_decimal, :billing_cycles, :service_period_days, :metered_quantity, :charge_once, :charge_on_option, :charge_on_event
10 | end
11 |
12 | class CouponsToAdd < Model
13 | attr_accessor :coupon_id, :apply_till
14 | end
15 |
16 | class DiscountsToAdd < Model
17 | attr_accessor :id, :invoice_name, :type, :percentage, :amount, :duration_type, :period, :period_unit, :included_in_mrr, :apply_on, :item_price_id, :created_at
18 | end
19 |
20 | class ItemTier < Model
21 | attr_accessor :item_price_id, :starting_unit, :ending_unit, :price, :starting_unit_in_decimal, :ending_unit_in_decimal, :price_in_decimal, :pricing_type, :package_size, :index
22 | end
23 |
24 | class ContractTerm < Model
25 | attr_accessor :cancellation_cutoff_period, :renewal_billing_cycles, :action_at_term_end
26 | end
27 |
28 | class StatusTransitionReason < Model
29 | attr_accessor :code, :message
30 | end
31 |
32 | attr_accessor :id, :description, :subscription_id, :effective_from, :status, :created_at, :resource_version,
33 | :updated_at, :items_to_add, :items_to_update, :coupons_to_add, :discounts_to_add, :item_tiers,
34 | :items_to_remove, :coupons_to_remove, :discounts_to_remove, :contract_term, :deleted, :status_transition_reason
35 |
36 | # OPERATIONS
37 | #-----------
38 |
39 | def self.create_for_subscription(id, params, env=nil, headers={})
40 | jsonKeys = {
41 | }
42 | options = {
43 | :isIdempotent => true
44 | }
45 | Request.send('post', uri_path("subscriptions",id.to_s,"create_ramp"), params, env, headers,nil, false, jsonKeys, options)
46 | end
47 |
48 | def self.update(id, params, env=nil, headers={})
49 | jsonKeys = {
50 | }
51 | options = {
52 | :isIdempotent => true
53 | }
54 | Request.send('post', uri_path("ramps",id.to_s,"update"), params, env, headers,nil, false, jsonKeys, options)
55 | end
56 |
57 | def self.retrieve(id, env=nil, headers={})
58 | jsonKeys = {
59 | }
60 | options = {}
61 | Request.send('get', uri_path("ramps",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
62 | end
63 |
64 | def self.delete(id, env=nil, headers={})
65 | jsonKeys = {
66 | }
67 | options = {
68 | :isIdempotent => true
69 | }
70 | Request.send('post', uri_path("ramps",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
71 | end
72 |
73 | def self.list(params, env=nil, headers={})
74 | jsonKeys = {
75 | }
76 | options = {}
77 | Request.send_list_request('get', uri_path("ramps"), params, env, headers,nil, false, jsonKeys, options)
78 | end
79 |
80 | end # ~Ramp
81 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/recorded_purchase.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class RecordedPurchase < Model
3 |
4 | class LinkedOmnichannelSubscription < Model
5 | attr_accessor :omnichannel_subscription_id
6 | end
7 |
8 | class LinkedOmnichannelOneTimeOrder < Model
9 | attr_accessor :omnichannel_one_time_order_id
10 | end
11 |
12 | class ErrorDetail < Model
13 | attr_accessor :error_message
14 | end
15 |
16 | attr_accessor :id, :customer_id, :app_id, :source, :status, :omnichannel_transaction_id, :created_at,
17 | :resource_version, :linked_omnichannel_subscriptions, :linked_omnichannel_one_time_orders, :error_detail
18 |
19 | # OPERATIONS
20 | #-----------
21 |
22 | def self.create(params, env=nil, headers={})
23 | jsonKeys = {
24 | }
25 | options = {
26 | :isIdempotent => true
27 | }
28 | Request.send('post', uri_path("recorded_purchases"), params, env, headers,nil, false, jsonKeys, options)
29 | end
30 |
31 | def self.retrieve(id, env=nil, headers={})
32 | jsonKeys = {
33 | }
34 | options = {}
35 | Request.send('get', uri_path("recorded_purchases",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
36 | end
37 |
38 | end # ~RecordedPurchase
39 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/resource_migration.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ResourceMigration < Model
3 |
4 | attr_accessor :from_site, :entity_type, :entity_id, :status, :errors, :created_at, :updated_at
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.retrieve_latest(params, env=nil, headers={})
10 | jsonKeys = {
11 | }
12 | options = {}
13 | Request.send('get', uri_path("resource_migrations","retrieve_latest"), params, env, headers,nil, false, jsonKeys, options)
14 | end
15 |
16 | end # ~ResourceMigration
17 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/rule.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Rule < Model
3 |
4 | attr_accessor :id, :namespace, :rule_name, :rule_order, :status, :conditions, :outcome, :deleted,
5 | :created_at, :modified_at
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.retrieve(id, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {}
14 | Request.send('get', uri_path("rules",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
15 | end
16 |
17 | end # ~Rule
18 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/site_migration_detail.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class SiteMigrationDetail < Model
3 |
4 | attr_accessor :entity_id, :other_site_name, :entity_id_at_other_site, :migrated_at, :entity_type,
5 | :status
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.list(params={}, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {}
14 | Request.send_list_request('get', uri_path("site_migration_details"), params, env, headers,nil, false, jsonKeys, options)
15 | end
16 |
17 | end # ~SiteMigrationDetail
18 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/subscription_entitlement.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class SubscriptionEntitlement < Model
3 |
4 | class Component < Model
5 | attr_accessor :entitlement_overrides
6 | end
7 |
8 | attr_accessor :subscription_id, :feature_id, :feature_name, :feature_unit, :feature_type, :value,
9 | :name, :is_overridden, :is_enabled, :effective_from, :schedule_status, :expires_at, :components
10 |
11 | # OPERATIONS
12 | #-----------
13 |
14 | def self.subscription_entitlements_for_subscription(id, params={}, env=nil, headers={})
15 | jsonKeys = {
16 | }
17 | options = {}
18 | Request.send('get', uri_path("subscriptions",id.to_s,"subscription_entitlements"), params, env, headers,nil, false, jsonKeys, options)
19 | end
20 |
21 | def self.set_subscription_entitlement_availability(id, params, env=nil, headers={})
22 | jsonKeys = {
23 | }
24 | options = {
25 | :isIdempotent => true
26 | }
27 | Request.send('post', uri_path("subscriptions",id.to_s,"subscription_entitlements/set_availability"), params, env, headers,nil, false, jsonKeys, options)
28 | end
29 |
30 | end # ~SubscriptionEntitlement
31 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/subscription_entitlements_created_detail.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class SubscriptionEntitlementsCreatedDetail < Model
3 |
4 | attr_accessor :subscription_id, :has_next
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~SubscriptionEntitlementsCreatedDetail
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/subscription_entitlements_updated_detail.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class SubscriptionEntitlementsUpdatedDetail < Model
3 |
4 | attr_accessor :subscription_id, :has_next
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~SubscriptionEntitlementsUpdatedDetail
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/subscription_estimate.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class SubscriptionEstimate < Model
3 |
4 | class ShippingAddress < Model
5 | attr_accessor :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip, :validation_status
6 | end
7 |
8 | class ContractTerm < Model
9 | attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end, :total_contract_value, :total_contract_value_before_tax, :cancellation_cutoff_period, :created_at, :subscription_id, :remaining_billing_cycles
10 | end
11 |
12 | attr_accessor :id, :currency_code, :status, :trial_end_action, :next_billing_at, :pause_date,
13 | :resume_date, :shipping_address, :contract_term
14 |
15 | # OPERATIONS
16 | #-----------
17 |
18 | end # ~SubscriptionEstimate
19 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/tax_withheld.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class TaxWithheld < Model
3 |
4 | attr_accessor :id, :user, :reference_number, :description, :type, :payment_method, :date, :currency_code,
5 | :amount, :resource_version, :updated_at, :exchange_rate
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | end # ~TaxWithheld
11 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/third_party_payment_method.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class ThirdPartyPaymentMethod < Model
3 |
4 | attr_accessor :type, :gateway, :gateway_account_id, :reference_id
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | end # ~ThirdPartyPaymentMethod
10 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/time_machine.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class TimeMachine < Model
3 |
4 | attr_accessor :name, :time_travel_status, :genesis_time, :destination_time, :failure_code, :failure_reason,
5 | :error_json
6 |
7 | def wait_for_time_travel_completion(env = nil)
8 | env = env || ChargeBee.default_env
9 | sleeptime = env.time_machine_sleeptime
10 |
11 | tm = (1..30).inject(self) do |time_machine|
12 | break time_machine if time_machine.time_travel_status != "in_progress"
13 | sleep(sleeptime)
14 | self.class.retrieve(self.name, env).time_machine
15 | end
16 |
17 | # sync last fetched one with the current instance
18 | new_values = tm.instance_variable_get("@values")
19 | self.instance_variable_set("@values", new_values)
20 | self.load(new_values)
21 |
22 | case tm.time_travel_status
23 | when "in_progress"
24 | raise Error.new('The time travel is taking too much time')
25 | when "failed"
26 | json_obj = Util.symbolize_keys(JSON.parse(self.error_json))
27 | raise OperationFailedError.new(json_obj[:http_code], json_obj)
28 | when "not_enabled", "_unknown"
29 | raise Error.new("Time travel status is in wrong state #{self.time_travel_status}")
30 | end
31 | end
32 |
33 | # OPERATIONS
34 | #-----------
35 |
36 | def self.retrieve(id, env=nil, headers={})
37 | jsonKeys = {
38 | }
39 | options = {}
40 | Request.send('get', uri_path("time_machines",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
41 | end
42 |
43 | def self.start_afresh(id, params={}, env=nil, headers={})
44 | jsonKeys = {
45 | }
46 | options = {
47 | :isIdempotent => true
48 | }
49 | Request.send('post', uri_path("time_machines",id.to_s,"start_afresh"), params, env, headers,nil, false, jsonKeys, options)
50 | end
51 |
52 | def self.travel_forward(id, params={}, env=nil, headers={})
53 | jsonKeys = {
54 | }
55 | options = {
56 | :isIdempotent => true
57 | }
58 | Request.send('post', uri_path("time_machines",id.to_s,"travel_forward"), params, env, headers,nil, false, jsonKeys, options)
59 | end
60 |
61 | end # ~TimeMachine
62 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/token.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Token < Model
3 |
4 | attr_accessor :id, :gateway, :gateway_account_id, :payment_method_type, :status, :id_at_vault,
5 | :vault, :ip_address, :resource_version, :updated_at, :created_at, :expired_at
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | end # ~Token
11 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/transaction.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Transaction < Model
3 |
4 | class LinkedInvoice < Model
5 | attr_accessor :invoice_id, :applied_amount, :applied_at, :invoice_date, :invoice_total, :invoice_status
6 | end
7 |
8 | class LinkedCreditNote < Model
9 | attr_accessor :cn_id, :applied_amount, :applied_at, :cn_reason_code, :cn_create_reason_code, :cn_date, :cn_total, :cn_status, :cn_reference_invoice_id
10 | end
11 |
12 | class LinkedRefund < Model
13 | attr_accessor :txn_id, :txn_status, :txn_date, :txn_amount
14 | end
15 |
16 | class LinkedPayment < Model
17 | attr_accessor :id, :status, :amount, :date
18 | end
19 |
20 | class GatewayErrorDetail < Model
21 | attr_accessor :request_id, :error_category, :error_code, :error_message, :decline_code, :decline_message, :network_error_code, :network_error_message, :error_field, :recommendation_code, :recommendation_message, :processor_error_code, :processor_error_message, :error_cause_id, :processor_advice_code
22 | end
23 |
24 | attr_accessor :id, :customer_id, :subscription_id, :gateway_account_id, :payment_source_id,
25 | :payment_method, :reference_number, :gateway, :type, :date, :settled_at, :exchange_rate, :currency_code,
26 | :amount, :id_at_gateway, :status, :fraud_flag, :initiator_type, :three_d_secure, :authorization_reason,
27 | :error_code, :error_text, :voided_at, :resource_version, :updated_at, :fraud_reason, :custom_payment_method_id,
28 | :amount_unused, :masked_card_number, :reference_transaction_id, :refunded_txn_id, :reference_authorization_id,
29 | :amount_capturable, :reversal_transaction_id, :linked_invoices, :linked_credit_notes, :linked_refunds,
30 | :linked_payments, :deleted, :iin, :last4, :merchant_reference_id, :business_entity_id, :payment_method_details,
31 | :error_detail, :custom_payment_method_name
32 |
33 | # OPERATIONS
34 | #-----------
35 |
36 | def self.create_authorization(params, env=nil, headers={})
37 | jsonKeys = {
38 | }
39 | options = {
40 | :isIdempotent => true
41 | }
42 | Request.send('post', uri_path("transactions","create_authorization"), params, env, headers,nil, false, jsonKeys, options)
43 | end
44 |
45 | def self.void_transaction(id, env=nil, headers={})
46 | jsonKeys = {
47 | }
48 | options = {
49 | :isIdempotent => true
50 | }
51 | Request.send('post', uri_path("transactions",id.to_s,"void"), {}, env, headers,nil, false, jsonKeys, options)
52 | end
53 |
54 | def self.record_refund(id, params, env=nil, headers={})
55 | jsonKeys = {
56 | }
57 | options = {
58 | :isIdempotent => true
59 | }
60 | Request.send('post', uri_path("transactions",id.to_s,"record_refund"), params, env, headers,nil, false, jsonKeys, options)
61 | end
62 |
63 | def self.reconcile(id, params={}, env=nil, headers={})
64 | jsonKeys = {
65 | }
66 | options = {
67 | :isIdempotent => true
68 | }
69 | Request.send('post', uri_path("transactions",id.to_s,"reconcile"), params, env, headers,nil, false, jsonKeys, options)
70 | end
71 |
72 | def self.refund(id, params={}, env=nil, headers={})
73 | jsonKeys = {
74 | }
75 | options = {
76 | :isIdempotent => true
77 | }
78 | Request.send('post', uri_path("transactions",id.to_s,"refund"), params, env, headers,nil, false, jsonKeys, options)
79 | end
80 |
81 | def self.list(params={}, env=nil, headers={})
82 | jsonKeys = {
83 | }
84 | options = {}
85 | Request.send_list_request('get', uri_path("transactions"), params, env, headers,nil, false, jsonKeys, options)
86 | end
87 |
88 | def self.transactions_for_customer(id, params={}, env=nil, headers={})
89 | jsonKeys = {
90 | }
91 | options = {}
92 | Request.send('get', uri_path("customers",id.to_s,"transactions"), params, env, headers,nil, false, jsonKeys, options)
93 | end
94 |
95 | def self.transactions_for_subscription(id, params={}, env=nil, headers={})
96 | jsonKeys = {
97 | }
98 | options = {}
99 | Request.send('get', uri_path("subscriptions",id.to_s,"transactions"), params, env, headers,nil, false, jsonKeys, options)
100 | end
101 |
102 | def self.payments_for_invoice(id, params={}, env=nil, headers={})
103 | jsonKeys = {
104 | }
105 | options = {}
106 | Request.send('get', uri_path("invoices",id.to_s,"payments"), params, env, headers,nil, false, jsonKeys, options)
107 | end
108 |
109 | def self.retrieve(id, env=nil, headers={})
110 | jsonKeys = {
111 | }
112 | options = {}
113 | Request.send('get', uri_path("transactions",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
114 | end
115 |
116 | def self.delete_offline_transaction(id, params={}, env=nil, headers={})
117 | jsonKeys = {
118 | }
119 | options = {
120 | :isIdempotent => true
121 | }
122 | Request.send('post', uri_path("transactions",id.to_s,"delete_offline_transaction"), params, env, headers,nil, false, jsonKeys, options)
123 | end
124 |
125 | end # ~Transaction
126 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/unbilled_charge.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class UnbilledCharge < Model
3 |
4 | class Tier < Model
5 | attr_accessor :starting_unit, :ending_unit, :quantity_used, :unit_amount, :starting_unit_in_decimal, :ending_unit_in_decimal, :quantity_used_in_decimal, :unit_amount_in_decimal, :pricing_type, :package_size
6 | end
7 |
8 | attr_accessor :id, :customer_id, :subscription_id, :date_from, :date_to, :unit_amount, :pricing_model,
9 | :quantity, :amount, :currency_code, :discount_amount, :description, :entity_type, :entity_id,
10 | :is_voided, :voided_at, :unit_amount_in_decimal, :quantity_in_decimal, :amount_in_decimal, :updated_at,
11 | :tiers, :is_advance_charge, :business_entity_id, :deleted
12 |
13 | # OPERATIONS
14 | #-----------
15 |
16 | def self.create_unbilled_charge(params, env=nil, headers={})
17 | jsonKeys = {
18 | }
19 | options = {
20 | :isIdempotent => true
21 | }
22 | Request.send('post', uri_path("unbilled_charges","create"), params, env, headers,nil, false, jsonKeys, options)
23 | end
24 |
25 | def self.create(params, env=nil, headers={})
26 | jsonKeys = {
27 | }
28 | options = {
29 | :isIdempotent => true
30 | }
31 | Request.send('post', uri_path("unbilled_charges"), params, env, headers,nil, false, jsonKeys, options)
32 | end
33 |
34 | def self.invoice_unbilled_charges(params={}, env=nil, headers={})
35 | jsonKeys = {
36 | }
37 | options = {
38 | :isIdempotent => true
39 | }
40 | Request.send('post', uri_path("unbilled_charges","invoice_unbilled_charges"), params, env, headers,nil, false, jsonKeys, options)
41 | end
42 |
43 | def self.delete(id, env=nil, headers={})
44 | jsonKeys = {
45 | }
46 | options = {
47 | :isIdempotent => true
48 | }
49 | Request.send('post', uri_path("unbilled_charges",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
50 | end
51 |
52 | def self.list(params={}, env=nil, headers={})
53 | jsonKeys = {
54 | }
55 | options = {}
56 | Request.send_list_request('get', uri_path("unbilled_charges"), params, env, headers,nil, false, jsonKeys, options)
57 | end
58 |
59 | def self.invoice_now_estimate(params={}, env=nil, headers={})
60 | jsonKeys = {
61 | }
62 | options = {}
63 | Request.send('post', uri_path("unbilled_charges","invoice_now_estimate"), params, env, headers,nil, false, jsonKeys, options)
64 | end
65 |
66 | end # ~UnbilledCharge
67 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/usage.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Usage < Model
3 |
4 | attr_accessor :id, :usage_date, :subscription_id, :item_price_id, :invoice_id, :line_item_id,
5 | :quantity, :source, :note, :resource_version, :updated_at, :created_at
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.create(id, params, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {
14 | :isIdempotent => true
15 | }
16 | Request.send('post', uri_path("subscriptions",id.to_s,"usages"), params, env, headers,nil, false, jsonKeys, options)
17 | end
18 |
19 | def self.retrieve(id, params, env=nil, headers={})
20 | jsonKeys = {
21 | }
22 | options = {}
23 | Request.send('get', uri_path("subscriptions",id.to_s,"usages"), params, env, headers,nil, false, jsonKeys, options)
24 | end
25 |
26 | def self.delete(id, params, env=nil, headers={})
27 | jsonKeys = {
28 | }
29 | options = {
30 | :isIdempotent => true
31 | }
32 | Request.send('post', uri_path("subscriptions",id.to_s,"delete_usage"), params, env, headers,nil, false, jsonKeys, options)
33 | end
34 |
35 | def self.list(params={}, env=nil, headers={})
36 | jsonKeys = {
37 | }
38 | options = {}
39 | Request.send_list_request('get', uri_path("usages"), params, env, headers,nil, false, jsonKeys, options)
40 | end
41 |
42 | def self.pdf(params, env=nil, headers={})
43 | jsonKeys = {
44 | }
45 | options = {
46 | :isIdempotent => true
47 | }
48 | Request.send('post', uri_path("usages","pdf"), params, env, headers,nil, false, jsonKeys, options)
49 | end
50 |
51 | end # ~Usage
52 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/usage_event.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class UsageEvent < Model
3 |
4 | attr_accessor :subscription_id, :deduplication_id, :usage_timestamp, :properties
5 |
6 | # OPERATIONS
7 | #-----------
8 |
9 | def self.create(params, env=nil, headers={})
10 | jsonKeys = {
11 | :properties => 0,
12 | }
13 | options = {}
14 | Request.send('post', uri_path("usage_events"), params, env, headers, "ingest", true, jsonKeys, options)
15 | end
16 |
17 | def self.batch_ingest(params, env=nil, headers={})
18 | jsonKeys = {
19 | :properties => 1,
20 | }
21 | options = {}
22 | Request.send('post', uri_path("batch","usage_events"), params, env, headers, "ingest", true, jsonKeys, options)
23 | end
24 |
25 | end # ~UsageEvent
26 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/usage_file.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class UsageFile < Model
3 |
4 | class UploadDetail < Model
5 | attr_accessor :url, :expires_at
6 | end
7 |
8 | attr_accessor :id, :name, :mime_type, :error_code, :error_reason, :status, :total_records_count,
9 | :processed_records_count, :failed_records_count, :file_size_in_bytes, :processing_started_at,
10 | :processing_completed_at, :uploaded_by, :uploaded_at, :error_file_path, :error_file_url, :upload_details
11 |
12 | # OPERATIONS
13 | #-----------
14 |
15 | def self.upload_url(params, env=nil, headers={})
16 | jsonKeys = {
17 | }
18 | options = {}
19 | Request.send('post', uri_path("usage_files","upload_url"), params, env, headers, "file-ingest", false, jsonKeys, options)
20 | end
21 |
22 | def self.processing_status(id, env=nil, headers={})
23 | jsonKeys = {
24 | }
25 | options = {}
26 | Request.send('get', uri_path("usage_files",id.to_s,"processing_status"), {}, env, headers, "file-ingest", false, jsonKeys, options)
27 | end
28 |
29 | end # ~UsageFile
30 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/virtual_bank_account.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class VirtualBankAccount < Model
3 |
4 | attr_accessor :id, :customer_id, :email, :scheme, :bank_name, :account_number, :routing_number,
5 | :swift_code, :gateway, :gateway_account_id, :resource_version, :updated_at, :created_at, :reference_id,
6 | :deleted
7 |
8 | # OPERATIONS
9 | #-----------
10 |
11 | def self.create_using_permanent_token(params, env=nil, headers={})
12 | jsonKeys = {
13 | }
14 | options = {
15 | :isIdempotent => true
16 | }
17 | Request.send('post', uri_path("virtual_bank_accounts","create_using_permanent_token"), params, env, headers,nil, false, jsonKeys, options)
18 | end
19 |
20 | def self.create(params, env=nil, headers={})
21 | jsonKeys = {
22 | }
23 | options = {
24 | :isIdempotent => true
25 | }
26 | Request.send('post', uri_path("virtual_bank_accounts"), params, env, headers,nil, false, jsonKeys, options)
27 | end
28 |
29 | def self.retrieve(id, env=nil, headers={})
30 | jsonKeys = {
31 | }
32 | options = {}
33 | Request.send('get', uri_path("virtual_bank_accounts",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
34 | end
35 |
36 | def self.list(params={}, env=nil, headers={})
37 | jsonKeys = {
38 | }
39 | options = {}
40 | Request.send_list_request('get', uri_path("virtual_bank_accounts"), params, env, headers,nil, false, jsonKeys, options)
41 | end
42 |
43 | def self.delete(id, env=nil, headers={})
44 | jsonKeys = {
45 | }
46 | options = {
47 | :isIdempotent => true
48 | }
49 | Request.send('post', uri_path("virtual_bank_accounts",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
50 | end
51 |
52 | def self.delete_local(id, env=nil, headers={})
53 | jsonKeys = {
54 | }
55 | options = {
56 | :isIdempotent => true
57 | }
58 | Request.send('post', uri_path("virtual_bank_accounts",id.to_s,"delete_local"), {}, env, headers,nil, false, jsonKeys, options)
59 | end
60 |
61 | end # ~VirtualBankAccount
62 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/models/webhook_endpoint.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class WebhookEndpoint < Model
3 |
4 | attr_accessor :id, :name, :url, :send_card_resource, :disabled, :primary_url, :api_version,
5 | :chargebee_response_schema_type, :enabled_events
6 |
7 | # OPERATIONS
8 | #-----------
9 |
10 | def self.create(params, env=nil, headers={})
11 | jsonKeys = {
12 | }
13 | options = {
14 | :isIdempotent => true
15 | }
16 | Request.send('post', uri_path("webhook_endpoints"), params, env, headers,nil, false, jsonKeys, options)
17 | end
18 |
19 | def self.update(id, params={}, env=nil, headers={})
20 | jsonKeys = {
21 | }
22 | options = {
23 | :isIdempotent => true
24 | }
25 | Request.send('post', uri_path("webhook_endpoints",id.to_s), params, env, headers,nil, false, jsonKeys, options)
26 | end
27 |
28 | def self.retrieve(id, env=nil, headers={})
29 | jsonKeys = {
30 | }
31 | options = {}
32 | Request.send('get', uri_path("webhook_endpoints",id.to_s), {}, env, headers,nil, false, jsonKeys, options)
33 | end
34 |
35 | def self.delete(id, env=nil, headers={})
36 | jsonKeys = {
37 | }
38 | options = {
39 | :isIdempotent => true
40 | }
41 | Request.send('post', uri_path("webhook_endpoints",id.to_s,"delete"), {}, env, headers,nil, false, jsonKeys, options)
42 | end
43 |
44 | def self.list(params={}, env=nil, headers={})
45 | jsonKeys = {
46 | }
47 | options = {}
48 | Request.send_list_request('get', uri_path("webhook_endpoints"), params, env, headers,nil, false, jsonKeys, options)
49 | end
50 |
51 | end # ~WebhookEndpoint
52 | end # ~ChargeBee
--------------------------------------------------------------------------------
/lib/chargebee/request.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | class Request
3 |
4 | def self.send_list_request(method, url, params={}, env=nil, headers={}, sub_domain=nil, isJsonRequest=nil, jsonKeys={}, options={})
5 | serialized = {}
6 | params.each do |k, v|
7 | if(v.kind_of? Array)
8 | v = v.to_json
9 | end
10 | serialized["#{k}"] = v
11 | end
12 | self.send(method, url, serialized, env, headers, sub_domain, isJsonRequest=nil, jsonKeys={}, options)
13 | end
14 |
15 | def self.send(method, url, params={}, env=nil, headers={}, sub_domain=nil, isJsonRequest=nil, jsonKeys={}, options={})
16 | env ||= ChargeBee.default_env
17 | ser_params = isJsonRequest ? params : Util.serialize(params, nil, nil, jsonKeys)
18 | resp, rheaders, rcode = NativeRequest.request(method, url, env, ser_params||={}, headers, sub_domain, isJsonRequest, options)
19 | if resp&.has_key?(:list)
20 | ListResult.new(resp[:list], resp[:next_offset], rheaders, rcode)
21 | else
22 | Result.new(resp, rheaders, rcode)
23 | end
24 | end
25 |
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/lib/chargebee/rest.rb:
--------------------------------------------------------------------------------
1 | require 'rest_client'
2 | require 'json'
3 |
4 | module ChargeBee
5 | module Rest
6 |
7 | def self.request(method, url, env, params=nil, headers={})
8 | raise Error.new('No environment configured.') unless env
9 | api_key = env.api_key
10 |
11 | if(ChargeBee.verify_ca_certs?)
12 | ssl_opts = {
13 | :verify_ssl => OpenSSL::SSL::VERIFY_PEER,
14 | :ssl_ca_file => ChargeBee.ca_cert_path
15 | }
16 | else
17 | ssl_opts = {
18 | :verify_ssl => false
19 | }
20 | end
21 | case method.to_s.downcase.to_sym
22 | when :get, :head, :delete
23 | headers = { :params => params }.merge(headers)
24 | payload = nil
25 | else
26 | payload = params
27 | end
28 |
29 | user_agent = ChargeBee.user_agent
30 | headers = {
31 | "User-Agent" => user_agent,
32 | :accept => :json,
33 | "Lang-Version" => RUBY_VERSION,
34 | "OS-Version" => RUBY_PLATFORM
35 | }.merge(headers)
36 | opts = {
37 | :method => method,
38 | :url => env.api_url(url),
39 | :user => api_key,
40 | :headers => headers,
41 | :payload => payload,
42 | :open_timeout => env.connect_timeout,
43 | :timeout => env.read_timeout
44 | }.merge(ssl_opts)
45 |
46 | begin
47 | response = RestClient::Request.execute(opts)
48 | rescue RestClient::ExceptionWithResponse => e
49 | if rcode = e.http_code and rbody = e.http_body
50 | raise handle_for_error(e, rcode, rbody)
51 | else
52 | raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)
53 | end
54 | rescue Exception => e
55 | raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)
56 | end
57 | rheaders = response.headers
58 | rbody = response.body
59 | rcode = response.code
60 | begin
61 | resp = JSON.parse(rbody)
62 | rescue Exception => e
63 | if rbody.include? "503"
64 | raise Error.new("Sorry, the server is currently unable to handle the request due to a temporary overload or scheduled maintenance. Please retry after sometime. \n type: internal_temporary_error, \n http_status_code: 503, \n error_code: internal_temporary_error,\n content: #{rbody.inspect}",e)
65 | elsif rbody.include? "504"
66 | raise Error.new("The server did not receive a timely response from an upstream server, request aborted. If this problem persists, contact us at support@chargebee.com. \n type: gateway_timeout, \n http_status_code: 504, \n error_code: gateway_timeout,\n content: #{rbody.inspect}",e)
67 | else
68 | raise Error.new("Sorry, something went wrong when trying to process the request. If this problem persists, contact us at support@chargebee.com. \n type: internal_error, \n http_status_code: 500, \n error_code: internal_error,\n content: #{rbody.inspect}",e)
69 | end
70 | end
71 | resp = Util.symbolize_keys(resp)
72 | return resp, rheaders
73 | end
74 |
75 | def self.handle_for_error(e, rcode=nil, rbody=nil)
76 | if(rcode == 204)
77 | raise Error.new("No response returned by the chargebee api. The http status code is #{rcode}")
78 | end
79 | begin
80 | error_obj = JSON.parse(rbody)
81 | error_obj = Util.symbolize_keys(error_obj)
82 | rescue Exception => e
83 | raise Error.new("Error response not in JSON format. The http status code is #{rcode} \n #{rbody.inspect}",e)
84 | end
85 | type = error_obj[:type]
86 | if("payment" == type)
87 | raise PaymentError.new(rcode, error_obj)
88 | elsif("operation_failed" == type)
89 | raise OperationFailedError.new(rcode, error_obj)
90 | elsif("invalid_request" == type)
91 | raise InvalidRequestError.new(rcode, error_obj)
92 | else
93 | raise APIError.new(rcode, error_obj)
94 | end
95 |
96 | end
97 |
98 | end
99 | end
100 |
--------------------------------------------------------------------------------
/lib/chargebee/util.rb:
--------------------------------------------------------------------------------
1 | module ChargeBee
2 | module Util
3 |
4 | def self.serialize(value, prefix = nil, idx = nil, json_keys = nil, level = 0)
5 | serialized = {}
6 | case value
7 | when Hash
8 | value.each do |k, v|
9 | should_json_encode = json_keys[k] && json_keys[k] == level
10 | if should_json_encode
11 | key = "#{prefix || ''}#{prefix ? "[#{k}]" : k}#{idx ? "[#{idx}]" : ''}"
12 | serialized.merge!({ key.to_s => v.is_a?(String) ? v : v.to_json })
13 | elsif(v.kind_of? Hash or v.kind_of? Array)
14 | temp_prefix = prefix!=nil ? "#{prefix}[#{k}]" : k
15 | serialized.merge!(serialize(v, temp_prefix, nil , json_keys, level+1))
16 | else
17 | key = "#{(prefix!=nil) ? prefix:''}#{(prefix!=nil) ? '['+k.to_s+']' : k}#{(idx != nil) ? '['+idx.to_s+']':''}"
18 | serialized.merge!({key => as_str(v)})
19 | end
20 | end
21 | when Array
22 | value.each_with_index do |v, i|
23 | serialized.merge!(serialize(v, prefix, i, json_keys, level))
24 | end
25 | else
26 | if(idx != nil and prefix != nil)
27 | key = "#{prefix}[#{idx.to_s}]"
28 | serialized.merge!({key => as_str(value)})
29 | else
30 | raise ArgumentError.new("only hash or arrays are allowed as value")
31 | end
32 | end
33 | serialized
34 | end
35 |
36 | def self.symbolize_keys(object)
37 | case object
38 | when Hash
39 | new = {}
40 | object.each do |key, value|
41 | key = (key.to_sym rescue key) || key
42 | new[key] = symbolize_keys(value)
43 | end
44 | new
45 | when Array
46 | object.map { |value| symbolize_keys(value) }
47 | else
48 | object
49 | end
50 | end
51 |
52 | def self.as_str(value)
53 | if(value == nil)
54 | return ''
55 | else
56 | return value.to_s
57 | end
58 | end
59 |
60 | end
61 | end
62 |
--------------------------------------------------------------------------------
/spec/chargebee/list_result_spec.rb:
--------------------------------------------------------------------------------
1 | require "spec_helper"
2 |
3 | describe ChargeBee::ListResult do
4 | let(:response) do
5 | {:list=>
6 | [{:customer=>
7 | {:id=>"d0cus3orh6gnjgha1i",
8 | :first_name=>"Test Name1",
9 | :last_name=>"Test last name 1",
10 | :email=>"name1@gmail.com",
11 | :auto_collection=>"on",
12 | :created_at=>1346258514,
13 | :object=>"customer",
14 | :card_status=>"valid"},
15 | :card=>
16 | {:customer_id=>"d0cus3orh6gnjgha1i",
17 | :status=>"valid",
18 | :gateway=>"chargebee",
19 | :first_name=>"Test Name1",
20 | :last_name=>"Test last name 1",
21 | :iin=>"32122",
22 | :last4=>"1333",
23 | :card_type=>"visa",
24 | :expiry_month=>8,
25 | :expiry_year=>2013,
26 | :billing_addr1=>"Flat 11",
27 | :billing_addr2=>"51 Strit",
28 | :billing_city=>"Bristol",
29 | :billing_state=>"Somerset",
30 | :billing_zip=>"BS1 4HQ",
31 | :object=>"card",
32 | :masked_number=>"21323****4323"}},
33 | {:customer=>
34 | {:id=>"cwtid6smh67tq3z51l",
35 | :first_name=>"Test Name 2",
36 | :last_name=>"Test last name 2",
37 | :email=>"name2@gmail.com",
38 | :auto_collection=>"on",
39 | :created_at=>1345724673,
40 | :object=>"customer",
41 | :card_status=>"no_card"}}],
42 | :next_offset=>"[\"1345724673000\",\"1510\"]"}
43 | end
44 |
45 | before do
46 | ChargeBee::NativeRequest.stubs(:request).returns(response)
47 | end
48 |
49 | it "returns list object, with next offset attribute" do
50 | list = ChargeBee::Request.send(:customer, "http://url.com", {:limit => 2})
51 | expect(list.next_offset).to eq("[\"1345724673000\", \"1510\"]")
52 | end
53 | end
54 |
--------------------------------------------------------------------------------
/spec/chargebee/native_request_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'zlib'
3 | require 'stringio'
4 |
5 | module ChargeBee
6 | describe NativeRequest do
7 | let(:env) do
8 | stub(
9 | api_key: "test_api_key",
10 | connect_timeout: 2,
11 | read_timeout: 5,
12 | retry_config: {
13 | enabled: true,
14 | max_retries: 2,
15 | delay_ms: 0.1,
16 | retry_on: [503, 429,504]
17 | },
18 | enable_debug_logs: false
19 | ).tap do |env_stub|
20 | env_stub.define_singleton_method(:api_url) do |url, subdomain|
21 | URI("https://#{subdomain || 'dummy'}.chargebee.com#{url}")
22 | end
23 | end
24 | end
25 |
26 |
27 | before do
28 | ChargeBee.stubs(:user_agent).returns("ChargeBee-TestAgent")
29 | ChargeBee.stubs(:verify_ca_certs?).returns(false)
30 | end
31 |
32 | it "sends a GET request with query params" do
33 | stub_request(:get, "https://dummy.chargebee.com/test").
34 | with(query: { "key" => "value" }).
35 | to_return(body: '{"result": "ok"}', status: 200, headers: { "Content-Type" => "application/json" })
36 |
37 | resp, headers, code = NativeRequest.request(:get, "/test", env, { "key" => "value" })
38 |
39 | expect(resp[:result]).to eq("ok")
40 | expect(code).to eq(200)
41 | end
42 |
43 | it "sends a POST request with URL-encoded payload" do
44 | stub_request(:post, "https://dummy.chargebee.com/test").
45 | with(body: "foo=bar").
46 | to_return(body: '{"success":true}', status: 200)
47 |
48 | resp, _, _ = NativeRequest.request(:post, "/test", env, { foo: "bar" })
49 | expect(resp[:success]).to eq(true)
50 | end
51 |
52 | it "sends a POST request with JSON payload when isJsonRequest=true" do
53 | stub_request(:post, "https://dummy.chargebee.com/test")
54 | .with(
55 | body: { foo: "bar" }.to_json, # match raw JSON string
56 | headers: {
57 | 'Accept' => 'application/json',
58 | 'Content-Type' => 'application/json;charset=UTF-8',
59 | 'User-Agent' => 'ChargeBee-TestAgent',
60 | 'Lang-Version' => RUBY_VERSION,
61 | 'OS-Version' => RUBY_PLATFORM,
62 | 'Authorization' => "Basic #{Base64.strict_encode64('test_api_key:')}"
63 | }
64 | )
65 | .to_return(status: 200, body: '{"success":true}', headers: { 'Content-Type' => 'application/json' })
66 |
67 | resp, _, _ = NativeRequest.request(:post, "/test", env, { foo: "bar" }, {}, nil, true)
68 | expect(resp[:success]).to eq(true)
69 | end
70 |
71 | it "retries on 503 with exponential backoff" do
72 | stub_request(:get, "https://dummy.chargebee.com/test")
73 | .to_return(
74 | {
75 | status: 503,
76 | body: {
77 | message: "Sorry, something went wrong when trying to process the request.",
78 | type: "operation_failed",
79 | api_error_code: "internal_error",
80 | error_code: "internal_error",
81 | error_msg: "Sorry, something went wrong when trying to process the request.",
82 | http_status_code: 500
83 | }.to_json,
84 | headers: { 'Content-Type' => 'application/json' }
85 | },
86 | {
87 | status: 200,
88 | body: { ok: true }.to_json,
89 | headers: { 'Content-Type' => 'application/json' }
90 | }
91 | )
92 |
93 | resp, _, code = NativeRequest.request(:get, "/test", env, {})
94 | expect(resp[:ok]).to eq(true)
95 | expect(code).to eq(200)
96 | end
97 |
98 | it "handles gzip compressed response body" do
99 | raw_json = '{"gzipped":true}'
100 | compressed = StringIO.new
101 | gz = Zlib::GzipWriter.new(compressed)
102 | gz.write(raw_json)
103 | gz.close
104 |
105 | stub_request(:get, "https://dummy.chargebee.com/test").
106 | to_return(body: compressed.string, headers: { "Content-Encoding" => "gzip" }, status: 200)
107 |
108 | resp, _, _ = NativeRequest.request(:get, "/test", env)
109 | expect(resp[:gzipped]).to eq(true)
110 | end
111 |
112 | it "raises error for 503 with JSON-like content" do
113 | stub_request(:get, "https://dummy.chargebee.com/test").
114 | to_return(body: "503 Service Unavailable", status: 503)
115 |
116 | expect {
117 | NativeRequest.request(:get, "/test", env)
118 | }.to raise_error(Error, /503/)
119 | end
120 |
121 | it "raises specific error types based on response type field" do
122 | ["payment", "operation_failed", "invalid_request", "other"].each do |type|
123 | error_json = { type: type, message: "error", api_error_code: "code", http_status_code: 400 }.to_json
124 | stub_request(:get, "https://dummy.chargebee.com/test").
125 | to_return(body: error_json, status: 400)
126 |
127 | expect {
128 | NativeRequest.request(:get, "/test", env)
129 | }.to raise_error do |err|
130 | case type
131 | when "payment"
132 | expect(err).to be_a(PaymentError)
133 | when "operation_failed"
134 | expect(err).to be_a(OperationFailedError)
135 | when "invalid_request"
136 | expect(err).to be_a(InvalidRequestError)
137 | else
138 | expect(err).to be_a(APIError)
139 | end
140 | end
141 | end
142 | end
143 |
144 | it "retries once on HTTP 503 and succeeds on second attempt" do
145 | stub_request(:get, "https://dummy.chargebee.com/test")
146 | .to_return({ status: 503, body: "temporary error" },
147 | { status: 200, body: '{"ok": true}', headers: { 'Content-Type' => 'application/json' } })
148 |
149 | resp, _, code = NativeRequest.request(:get, "/test", env)
150 | expect(resp[:ok]).to eq(true)
151 | expect(code).to eq(200)
152 | end
153 |
154 | it "uses Retry-After header if provided" do
155 | stub = stub_request(:get, "https://dummy.chargebee.com/test")
156 | .to_return(
157 | { status: 429, headers: { "Retry-After" => "0" }, body: "{}" },
158 | { status: 200, body: '{"done": true}', headers: { 'Content-Type' => 'application/json' } }
159 | )
160 |
161 | resp, _, code = NativeRequest.request(:get, "/test", env)
162 |
163 | expect(resp[:done]).to eq(true)
164 | expect(code).to eq(200)
165 | expect(stub).to have_been_requested.times(2)
166 | end
167 |
168 | it "raises after exhausting max_retries for retryable status codes" do
169 | stub_request(:get, "https://dummy.chargebee.com/test")
170 | .to_return(status: 503, body: "fail again")
171 |
172 | expect {
173 | NativeRequest.request(:get, "/test", env)
174 | }.to raise_error(Error, /503/)
175 | end
176 |
177 | it "retries on network errors like Timeout" do
178 | stub_request(:get, "https://dummy.chargebee.com/test")
179 | .to_timeout.then
180 | .to_return(status: 200, body: '{"hello":true}', headers: { 'Content-Type' => 'application/json' })
181 |
182 | resp, _, _ = NativeRequest.request(:get, "/test", env)
183 | expect(resp[:hello]).to eq(true)
184 | end
185 |
186 | it "retries on 504 and then succeeds" do
187 | stub_request(:get, "https://dummy.chargebee.com/test")
188 | .to_return(
189 | { status: 504, body: "gateway timeout" },
190 | { status: 200, body: '{"recovered":true}', headers: { 'Content-Type' => 'application/json' } }
191 | )
192 |
193 | resp, _, code = NativeRequest.request(:get, "/test", env)
194 | expect(resp[:recovered]).to eq(true)
195 | expect(code).to eq(200)
196 | end
197 |
198 | end
199 | end
--------------------------------------------------------------------------------
/spec/chargebee_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 | require 'sample_response'
3 |
4 | describe "chargebee" do
5 |
6 | before(:all) do
7 | @request = ChargeBee::NativeRequest
8 | end
9 |
10 | it "serialize should convert the hash to acceptable format" do
11 | json_keys = {}
12 | before = {
13 | :id => "sub_KyVq7DNSNM7CSD",
14 | :plan_id => "free",
15 | :addons => [{:id => "monitor", :quantity => 2}, {:id => "ssl"}],
16 | :addon_ids => ["addon_one", "addon_two"],
17 | :card => {
18 | :first_name => "Rajaraman",
19 | :last_name => "Santhanam",
20 | :number => "4111111111111111",
21 | :expiry_month => "1",
22 | :expiry_year => "2024",
23 | :cvv => "007"
24 | }
25 | }
26 | after = {
27 | "id"=>"sub_KyVq7DNSNM7CSD",
28 | "plan_id"=>"free",
29 | "addons[id][0]"=>"monitor",
30 | "addons[quantity][0]"=>"2",
31 | "addons[id][1]"=>"ssl",
32 | "addon_ids[0]"=>"addon_one",
33 | "addon_ids[1]"=>"addon_two",
34 | "card[first_name]"=>"Rajaraman",
35 | "card[last_name]"=>"Santhanam",
36 | "card[number]"=>"4111111111111111",
37 | "card[expiry_month]"=>"1",
38 | "card[expiry_year]"=>"2024",
39 | "card[cvv]"=>"007"}
40 | expect(ChargeBee::Util.serialize(before, nil, nil, json_keys)).to eq(after)
41 | end
42 |
43 | it "symbolize_keys should convert keys to symbols" do
44 | before = {
45 | 'id' => 'sub_KyVq4P__dev__NTWxbJx1',
46 | 'plan_id' => 'basic',
47 | 'addons' => [{ 'id' => 'ssl' }, {'id' => 'sms', 'quantity' => '10'}]
48 | }
49 | after = {
50 | :id => 'sub_KyVq4P__dev__NTWxbJx1',
51 | :plan_id => 'basic',
52 | :addons => [{ :id => 'ssl' }, {:id => 'sms', :quantity => '10'}],
53 | }
54 | expect(ChargeBee::Util.symbolize_keys(before)).to eq(after)
55 | end
56 |
57 | it "should properly convert the response json into proper object" do
58 | @request.expects(:request).once.returns([simple_subscription, headers])
59 | result = ChargeBee::Subscription.retrieve("simple_subscription")
60 | h = result.get_response_headers
61 | expect(h).to eq(headers)
62 | s = result.subscription
63 | expect(s.id).to eq("simple_subscription")
64 | expect(s.plan_id).to eq('basic')
65 | c = result.customer
66 | expect(c.first_name).to eq('simple')
67 | expect(c.last_name).to eq('subscription')
68 | end
69 |
70 | it "should properly convert the nested response json into proper object with sub types" do
71 | @request.expects(:request).once.returns([nested_subscription, headers])
72 | result = ChargeBee::Subscription.retrieve("nested_subscription")
73 | s = result.subscription
74 | expect(s.id).to eq("nested_subscription")
75 | a = s.addons
76 | expect(a.length).to eq(2)
77 | expect(a[0].id).to eq("monitor")
78 | expect(a[0].quantity).to eq("10")
79 | expect(a[1].id).to eq("ssl")
80 | end
81 |
82 | it "should properly convert the list response json into proper result object" do
83 | @request.expects(:request).once.returns([list_subscriptions, headers])
84 | result = ChargeBee::Subscription.list({:limit => 2})
85 | expect(result.length).to eq(2)
86 | result.each do |i|
87 | expect(i.subscription.id).to eq('sample_subscription')
88 | end
89 | end
90 |
91 | it "should parse event api response and provide the content properly" do
92 | @request.expects(:request).once.returns([sample_event, headers])
93 | result = ChargeBee::Event.retrieve("sample_event")
94 | event = result.event
95 | s = event.content.subscription
96 | expect(event.id).to eq('ev_KyVqDX__dev__NTgtUgx1')
97 | expect(s.id).to eq('sample_subscription')
98 | end
99 |
100 | end
101 |
102 |
--------------------------------------------------------------------------------
/spec/errors_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe 'ChargeBee::InvalidRequestError' do
4 | let(:invalid_request_json) do
5 | {
6 | message: 'id: The value chargebee_account is already present.',
7 | type: 'invalid_request',
8 | api_error_code: 'duplicate_entry',
9 | param: 'id',
10 | error_code: 'param_not_unique',
11 | error_msg: 'The value chargebee_account is already present.',
12 | error_param: 'id',
13 | http_status_code: 400
14 | }
15 | end
16 |
17 | it "provide message from error api response" do
18 | error = ChargeBee::InvalidRequestError.new(400, invalid_request_json)
19 | expect(error.message).to eq 'id: The value chargebee_account is already present.'
20 | end
21 |
22 | end
23 |
24 |
--------------------------------------------------------------------------------
/spec/sample_response.rb:
--------------------------------------------------------------------------------
1 |
2 | def api_index_urls()
3 | {
4 | :urls => ["http://mannar-test.localcb.com:8080/api/v1/subscriptions",
5 | "http://mannar-test.localcb.com:8080/api/v1/customers",
6 | "http://mannar-test.localcb.com:8080/api/v1/cards",
7 | "http://mannar-test.localcb.com:8080/api/v1/invoices",
8 | "http://mannar-test.localcb.com:8080/api/v1/transactions",
9 | "http://mannar-test.localcb.com:8080/api/v1/hosted_pages",
10 | "http://mannar-test.localcb.com:8080/api/v1/events"],
11 | :version => "v2"
12 | }
13 | end
14 |
15 | def headers
16 | {
17 | :cache_control=>"no-store, no-cache, must-revalidate",
18 | :pragma=>"no-cache",
19 | :content_type=>"application/json;charset=utf-8",
20 | :content_length=>"986",
21 | :date=>"Tue, 16 May 2023 08:12:00 GMT",
22 | :server=>"ChargeBee"
23 | }
24 | end
25 |
26 | def simple_subscription
27 | {
28 | :subscription => {
29 | :id => 'simple_subscription',
30 | :plan_id => 'basic'
31 | },
32 | :customer => {
33 | :first_name => 'simple',
34 | :last_name => 'subscription'
35 | }
36 | }
37 | end
38 |
39 | def nested_subscription
40 | {
41 | :subscription => {
42 | :id => 'nested_subscription',
43 | :plan_id => 'basic',
44 | :addons => [
45 | {:id => 'monitor', :quantity => '10'},
46 | {:id => 'ssl'}
47 | ]
48 | }
49 | }
50 | end
51 |
52 | def test_subscription
53 | {
54 | :subscription => {
55 | :id => "sample_subscription",
56 | :plan_id => "basic"
57 | }
58 | }
59 | end
60 |
61 | def list_subscriptions()
62 | {:list => [test_subscription, test_subscription]}
63 | end
64 |
65 | def sample_event()
66 | {:event => {
67 | :id => 'ev_KyVqDX__dev__NTgtUgx1',
68 | :occurred_at => 1325356232,
69 | :event_type => "payment_collected",
70 | :webhook_status => "succeeded",
71 | :content => {
72 | :subscription => {
73 | :id => 'sample_subscription',
74 | :plan_id => 'basic',
75 | :plan_quantity=> 1,
76 | },
77 | :customer => {
78 | :first_name => "Sample",
79 | :last_name => "Subscription",
80 | },
81 | }
82 | }
83 | }
84 | end
85 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require File.dirname(__FILE__) + '/../lib/chargebee'
2 |
3 | require 'rspec'
4 | require 'pp'
5 | require 'mocha'
6 | require 'json'
7 | require 'webmock/rspec'
8 | require 'base64'
9 |
10 | WebMock.disable_net_connect!(allow_localhost: true)
11 | RSpec.configure do |config|
12 | config.mock_with :mocha
13 | end
14 |
15 | def mock_response(body, code=200, headers)
16 | body = body.to_json if !(body.kind_of? String)
17 | m = mock
18 | m.instance_variable_set('@resp_values', { :body => body, :code => code, :headers => headers })
19 | def m.body; @resp_values[:body]; end
20 | def m.code; @resp_values[:code]; end
21 | def m.headers; @resp_values[:headers]; end
22 | m
23 | end
24 |
25 | ChargeBee.configure(
26 | :api_key => "dummy_api_key",
27 | :site => "dummy_site"
28 | )
29 |
--------------------------------------------------------------------------------