killbill-xml-builder


Namekillbill-xml-builder JSON
Version 0.0.9 PyPI version JSON
download
home_pageNone
Summarykillbill xml builder
upload_time2024-11-02 11:57:50
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords bill kill killbill xml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # killbill-xml-builder

- [Installation](#installation)
- [Usage](#usage)
- [TODO](#todo)

### Installation

```bash
pip install killbill-xml-builder
```

### Usage

Import the required classes and create the catalog

```python
from killbill_xml_builder.enums import (
    PhaseType,
    TimeUnit,
    BillingPeriod,
    BillingMode,
    ProductCategory,
    BillingPolicy,
    EntitlementPolicy,
)

from killbill_xml_builder import (
    Currencies,
    Product,
    Phase,
    Price,
    Duration,
    FixedPrice,
    RecurringPrice,
    Plan,
    Catalog,
    Rules,
    ChangePolicyCase,
    CancelPolicyCase,
)
```

Create currencies

```python
currencies = Currencies(["USD", "GBP"])
```

Create add-on

```python
oil_slick = Product("OilSlick", ProductCategory.ADD_ON)

remote_control = Product("RemoteControl", ProductCategory.ADD_ON)
```

Create products

```python
standard = Product("Standard")

sports = Product("Sports", available=[oil_slick, remote_control])

super = Product("Super", included=[oil_slick], available=[remote_control])
```

Create products phases

Phase trial

```python
phase_trial = Phase(
    type=PhaseType.TRIAL,
    duration=Duration(length=30, time_unit=TimeUnit.DAYS),
    fixed_price=FixedPrice(),
)
```

Phase standard evergreen

```python
standard_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 75.00), Price("USD", 100.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)
```

Phase sports evergreen

```python
sports_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 375.00), Price("USD", 500.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)
```

Phase super evergreen

```python
super_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 750.00), Price("USD", 1000.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)
```

Phase ADD-ON

```python
add_on_evergreen = Phase(
    type=PhaseType.EVERGREEN,
    duration=Duration(time_unit=TimeUnit.UNLIMITED),
    recurring_price=RecurringPrice(
        prices=[Price("GBP", 15.00), Price("USD", 20.00)],
        billing_period=BillingPeriod.MONTHLY,
    ),
)
```

Create rules (change and cancel rules are required)

```python
default_change_policy = ChangePolicyCase(policy=BillingPolicy.END_OF_TERM)

default_cancel_policy = CancelPolicyCase(policy=EntitlementPolicy.END_OF_TERM)

rules = Rules(
    change_policy_cases=[default_change_policy],
    cancel_policy_cases=[default_cancel_policy],
)
```

Create plans

```python
oil_slick_monthly = Plan(
    name="oil-slick-monthly",
    product=oil_slick,
    initial_phases=[],
    final_phase=add_on_evergreen,
)

remote_control_monthly = Plan(
    name="remote-control-monthly",
    product=remote_control,
    initial_phases=[],
    final_phase=add_on_evergreen,
)


standard_monthly = Plan(
    name="standard-monthly",
    product=standard,
    initial_phases=[phase_trial],
    final_phase=standard_evergreen,
)


sports_monthly = Plan(
    name="sports-monthly",
    product=sports,
    initial_phases=[phase_trial],
    final_phase=sports_evergreen,
)


super_monthly = Plan(
    name="super-monthly",
    product=super,
    initial_phases=[phase_trial],
    final_phase=super_evergreen,
)
```

Create catalog

```python
catalog = Catalog(
    name="SpyCarBasic",
    billing_mode=BillingMode.IN_ADVANCE,
    currencies=currencies,
    products=[standard, sports, super, oil_slick, remote_control],
    rules=rules,
    plans=[
        standard_monthly,
        sports_monthly,
        super_monthly,
        oil_slick_monthly,
        remote_control_monthly,
    ],
)
```

Get xml content

```python
print(catalog)
```

Save catalog as file

```python
catalog.write()
```

### TODO

#### Plans

- Usage

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "killbill-xml-builder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "bill, kill, killbill, xml",
    "author": null,
    "author_email": "Raul Cobiellas <raulodev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/42/6c/0533d23d183fc16ad084dd21b246124225868edc06eae2cc8e322c9091db/killbill_xml_builder-0.0.9.tar.gz",
    "platform": null,
    "description": "# killbill-xml-builder\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [TODO](#todo)\n\n### Installation\n\n```bash\npip install killbill-xml-builder\n```\n\n### Usage\n\nImport the required classes and create the catalog\n\n```python\nfrom killbill_xml_builder.enums import (\n    PhaseType,\n    TimeUnit,\n    BillingPeriod,\n    BillingMode,\n    ProductCategory,\n    BillingPolicy,\n    EntitlementPolicy,\n)\n\nfrom killbill_xml_builder import (\n    Currencies,\n    Product,\n    Phase,\n    Price,\n    Duration,\n    FixedPrice,\n    RecurringPrice,\n    Plan,\n    Catalog,\n    Rules,\n    ChangePolicyCase,\n    CancelPolicyCase,\n)\n```\n\nCreate currencies\n\n```python\ncurrencies = Currencies([\"USD\", \"GBP\"])\n```\n\nCreate add-on\n\n```python\noil_slick = Product(\"OilSlick\", ProductCategory.ADD_ON)\n\nremote_control = Product(\"RemoteControl\", ProductCategory.ADD_ON)\n```\n\nCreate products\n\n```python\nstandard = Product(\"Standard\")\n\nsports = Product(\"Sports\", available=[oil_slick, remote_control])\n\nsuper = Product(\"Super\", included=[oil_slick], available=[remote_control])\n```\n\nCreate products phases\n\nPhase trial\n\n```python\nphase_trial = Phase(\n    type=PhaseType.TRIAL,\n    duration=Duration(length=30, time_unit=TimeUnit.DAYS),\n    fixed_price=FixedPrice(),\n)\n```\n\nPhase standard evergreen\n\n```python\nstandard_evergreen = Phase(\n    type=PhaseType.EVERGREEN,\n    duration=Duration(time_unit=TimeUnit.UNLIMITED),\n    recurring_price=RecurringPrice(\n        prices=[Price(\"GBP\", 75.00), Price(\"USD\", 100.00)],\n        billing_period=BillingPeriod.MONTHLY,\n    ),\n)\n```\n\nPhase sports evergreen\n\n```python\nsports_evergreen = Phase(\n    type=PhaseType.EVERGREEN,\n    duration=Duration(time_unit=TimeUnit.UNLIMITED),\n    recurring_price=RecurringPrice(\n        prices=[Price(\"GBP\", 375.00), Price(\"USD\", 500.00)],\n        billing_period=BillingPeriod.MONTHLY,\n    ),\n)\n```\n\nPhase super evergreen\n\n```python\nsuper_evergreen = Phase(\n    type=PhaseType.EVERGREEN,\n    duration=Duration(time_unit=TimeUnit.UNLIMITED),\n    recurring_price=RecurringPrice(\n        prices=[Price(\"GBP\", 750.00), Price(\"USD\", 1000.00)],\n        billing_period=BillingPeriod.MONTHLY,\n    ),\n)\n```\n\nPhase ADD-ON\n\n```python\nadd_on_evergreen = Phase(\n    type=PhaseType.EVERGREEN,\n    duration=Duration(time_unit=TimeUnit.UNLIMITED),\n    recurring_price=RecurringPrice(\n        prices=[Price(\"GBP\", 15.00), Price(\"USD\", 20.00)],\n        billing_period=BillingPeriod.MONTHLY,\n    ),\n)\n```\n\nCreate rules (change and cancel rules are required)\n\n```python\ndefault_change_policy = ChangePolicyCase(policy=BillingPolicy.END_OF_TERM)\n\ndefault_cancel_policy = CancelPolicyCase(policy=EntitlementPolicy.END_OF_TERM)\n\nrules = Rules(\n    change_policy_cases=[default_change_policy],\n    cancel_policy_cases=[default_cancel_policy],\n)\n```\n\nCreate plans\n\n```python\noil_slick_monthly = Plan(\n    name=\"oil-slick-monthly\",\n    product=oil_slick,\n    initial_phases=[],\n    final_phase=add_on_evergreen,\n)\n\nremote_control_monthly = Plan(\n    name=\"remote-control-monthly\",\n    product=remote_control,\n    initial_phases=[],\n    final_phase=add_on_evergreen,\n)\n\n\nstandard_monthly = Plan(\n    name=\"standard-monthly\",\n    product=standard,\n    initial_phases=[phase_trial],\n    final_phase=standard_evergreen,\n)\n\n\nsports_monthly = Plan(\n    name=\"sports-monthly\",\n    product=sports,\n    initial_phases=[phase_trial],\n    final_phase=sports_evergreen,\n)\n\n\nsuper_monthly = Plan(\n    name=\"super-monthly\",\n    product=super,\n    initial_phases=[phase_trial],\n    final_phase=super_evergreen,\n)\n```\n\nCreate catalog\n\n```python\ncatalog = Catalog(\n    name=\"SpyCarBasic\",\n    billing_mode=BillingMode.IN_ADVANCE,\n    currencies=currencies,\n    products=[standard, sports, super, oil_slick, remote_control],\n    rules=rules,\n    plans=[\n        standard_monthly,\n        sports_monthly,\n        super_monthly,\n        oil_slick_monthly,\n        remote_control_monthly,\n    ],\n)\n```\n\nGet xml content\n\n```python\nprint(catalog)\n```\n\nSave catalog as file\n\n```python\ncatalog.write()\n```\n\n### TODO\n\n#### Plans\n\n- Usage\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "killbill xml builder",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/raulodev/killbill-xml-builder",
        "Issues": "https://github.com/raulodev/killbill-xml-builder/issues"
    },
    "split_keywords": [
        "bill",
        " kill",
        " killbill",
        " xml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a717e35a30f58b029ed075fedfa00e61a2decadb249c34a5476ba9fc0f577e8",
                "md5": "2eb3104227c500d1dcd99255fcc0b426",
                "sha256": "f6c3488a01327db269a6fa2da78f7e6a8cdd21b4a1e032b288fc7364d3de0ebd"
            },
            "downloads": -1,
            "filename": "killbill_xml_builder-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2eb3104227c500d1dcd99255fcc0b426",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11804,
            "upload_time": "2024-11-02T11:57:49",
            "upload_time_iso_8601": "2024-11-02T11:57:49.178835Z",
            "url": "https://files.pythonhosted.org/packages/2a/71/7e35a30f58b029ed075fedfa00e61a2decadb249c34a5476ba9fc0f577e8/killbill_xml_builder-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "426c0533d23d183fc16ad084dd21b246124225868edc06eae2cc8e322c9091db",
                "md5": "891889ab598ebde93912fb4279a217fe",
                "sha256": "355ca0232a054e0cd92a13738fa6c6654176233d17b3f8b8b5812b3203e4c330"
            },
            "downloads": -1,
            "filename": "killbill_xml_builder-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "891889ab598ebde93912fb4279a217fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7960,
            "upload_time": "2024-11-02T11:57:50",
            "upload_time_iso_8601": "2024-11-02T11:57:50.146034Z",
            "url": "https://files.pythonhosted.org/packages/42/6c/0533d23d183fc16ad084dd21b246124225868edc06eae2cc8e322c9091db/killbill_xml_builder-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-02 11:57:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "raulodev",
    "github_project": "killbill-xml-builder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "killbill-xml-builder"
}
        
Elapsed time: 1.10422s