From 5d58104d849efd81d9f298e0bc464e692a883f02 Mon Sep 17 00:00:00 2001 From: Margarida Silva Date: Thu, 10 Mar 2022 15:07:42 +0000 Subject: [PATCH 1/3] feat: added recent endpoints --- CHANGELOG.md | 2 +- src/ripe/invoice_rule.py | 10 ++++++++++ src/ripe/sku.py | 14 ++++++++++++-- src/ripe/transport_rule.py | 17 +++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fda09cd..fa2dff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* +* Added new `sku`, `invoice_rules` and `transport_rules` endpoints ### Changed diff --git a/src/ripe/invoice_rule.py b/src/ripe/invoice_rule.py index a85a71f..e4358cf 100644 --- a/src/ripe/invoice_rule.py +++ b/src/ripe/invoice_rule.py @@ -27,3 +27,13 @@ def delete_invoice_rule(self, id): url = self.base_url + "invoice_rules/%d" % id contents = self.delete(url) return contents + + def resolve_invoice_rules(self, brand = None, model = None, country = None): + url = self.base_url + "invoice_rules/resolve" + contents = self.get( + url, + brand = brand, + model = model, + country = country + ) + return contents \ No newline at end of file diff --git a/src/ripe/sku.py b/src/ripe/sku.py index c37c99e..0ac58ed 100644 --- a/src/ripe/sku.py +++ b/src/ripe/sku.py @@ -5,7 +5,12 @@ class SkuAPI(object): def list_skus(self): url = self.base_url + "skus" - contents = self.get(url, auth = False) + contents = self.get(url) + return contents + + def list_skus_csv(self): + url = self.base_url + "skus.csv" + contents = self.get(url) return contents def create_sku(self, sku): @@ -18,7 +23,7 @@ def create_sku(self, sku): def get_sku(self, id): url = self.base_url + "skus/%d" % id - contents = self.get(url, auth = False) + contents = self.get(url) return contents def update_sku(self, id, sku): @@ -38,3 +43,8 @@ def validate_sku(self, id): url = self.base_url + "skus/%s/validate" % id contents = self.get(url) return contents + + def count_skus(self): + url = self.base_url + "skus/count" + contents = self.get(url) + return contents diff --git a/src/ripe/transport_rule.py b/src/ripe/transport_rule.py index ccd0f19..a4aa9ce 100644 --- a/src/ripe/transport_rule.py +++ b/src/ripe/transport_rule.py @@ -27,3 +27,20 @@ def delete_transport_rule(self, id): url = self.base_url + "transport_rules/%d" % id contents = self.delete(url) return contents + + def resolve_transport_rules( + self, + brand = None, + model = None, + country = None, + factory = None + ): + url = self.base_url + "transport_rules/resolve" + contents = self.get( + url, + brand = brand, + model = model, + country = country, + factory = factory + ) + return contents From 356d889da0e55cd5a327ae6797e12f91753166c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Sat, 12 Mar 2022 11:50:48 +0000 Subject: [PATCH 2/3] fix: ran cleanup --- src/ripe/account.py | 2 +- src/ripe/availability_rule.py | 2 +- src/ripe/factory_rule.py | 2 +- src/ripe/invoice_rule.py | 78 +++++++++++++++++------------------ src/ripe/letter_rule.py | 2 +- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/ripe/account.py b/src/ripe/account.py index 1ddf548..75a6335 100644 --- a/src/ripe/account.py +++ b/src/ripe/account.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- class AccountAPI(object): - + def self_account(self, *args, **kwargs): url = self.base_url + "accounts/me" contents = self.get(url, **kwargs) diff --git a/src/ripe/availability_rule.py b/src/ripe/availability_rule.py index 7029d1e..55d6ac4 100644 --- a/src/ripe/availability_rule.py +++ b/src/ripe/availability_rule.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- class AvailabilityRuleAPI(object): - + def list_availability_rules(self, *args, **kwargs): url = self.base_url + "availability_rules" contents = self.get(url, **kwargs) diff --git a/src/ripe/factory_rule.py b/src/ripe/factory_rule.py index 7aa3618..c472346 100644 --- a/src/ripe/factory_rule.py +++ b/src/ripe/factory_rule.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- class FactoryRuleAPI(object): - + def list_factory_rules(self, *args, **kwargs): url = self.base_url + "factory_rules" contents = self.get(url, **kwargs) diff --git a/src/ripe/invoice_rule.py b/src/ripe/invoice_rule.py index e4358cf..8a62dba 100644 --- a/src/ripe/invoice_rule.py +++ b/src/ripe/invoice_rule.py @@ -1,39 +1,39 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -class InvoiceRuleAPI(object): - - def list_invoice_rules(self, *args, **kwargs): - url = self.base_url + "invoice_rules" - contents = self.get(url, **kwargs) - return contents - - def create_invoice_rule(self, invoice_rule): - url = self.base_url + "invoice_rules" - contents = self.post(url, data_j = invoice_rule) - return contents - - def get_invoice_rule(self, id): - url = self.base_url + "invoice_rules/%d" % id - contents = self.get(url) - return contents - - def update_invoice_rule(self, id, invoice_rule): - url = self.base_url + "invoice_rules/%d" % id - contents = self.put(url, data_j = invoice_rule) - return contents - - def delete_invoice_rule(self, id): - url = self.base_url + "invoice_rules/%d" % id - contents = self.delete(url) - return contents - - def resolve_invoice_rules(self, brand = None, model = None, country = None): - url = self.base_url + "invoice_rules/resolve" - contents = self.get( - url, - brand = brand, - model = model, - country = country - ) - return contents \ No newline at end of file +#!/usr/bin/python +# -*- coding: utf-8 -*- + +class InvoiceRuleAPI(object): + + def list_invoice_rules(self, *args, **kwargs): + url = self.base_url + "invoice_rules" + contents = self.get(url, **kwargs) + return contents + + def create_invoice_rule(self, invoice_rule): + url = self.base_url + "invoice_rules" + contents = self.post(url, data_j = invoice_rule) + return contents + + def get_invoice_rule(self, id): + url = self.base_url + "invoice_rules/%d" % id + contents = self.get(url) + return contents + + def update_invoice_rule(self, id, invoice_rule): + url = self.base_url + "invoice_rules/%d" % id + contents = self.put(url, data_j = invoice_rule) + return contents + + def delete_invoice_rule(self, id): + url = self.base_url + "invoice_rules/%d" % id + contents = self.delete(url) + return contents + + def resolve_invoice_rules(self, brand = None, model = None, country = None): + url = self.base_url + "invoice_rules/resolve" + contents = self.get( + url, + brand = brand, + model = model, + country = country + ) + return contents diff --git a/src/ripe/letter_rule.py b/src/ripe/letter_rule.py index c512baa..b0c981e 100644 --- a/src/ripe/letter_rule.py +++ b/src/ripe/letter_rule.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- class LetterRuleAPI(object): - + def list_letter_rules(self, *args, **kwargs): url = self.base_url + "letter_rules" contents = self.get(url, **kwargs) From 9383636b34280038dd508b9e60d985b2811ef4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Sat, 12 Mar 2022 11:52:19 +0000 Subject: [PATCH 3/3] fix: small method rename --- src/ripe/invoice_rule.py | 2 +- src/ripe/transport_rule.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ripe/invoice_rule.py b/src/ripe/invoice_rule.py index 8a62dba..21f34b3 100644 --- a/src/ripe/invoice_rule.py +++ b/src/ripe/invoice_rule.py @@ -28,7 +28,7 @@ def delete_invoice_rule(self, id): contents = self.delete(url) return contents - def resolve_invoice_rules(self, brand = None, model = None, country = None): + def resolve_invoice_rule(self, brand = None, model = None, country = None): url = self.base_url + "invoice_rules/resolve" contents = self.get( url, diff --git a/src/ripe/transport_rule.py b/src/ripe/transport_rule.py index a4aa9ce..a1f4697 100644 --- a/src/ripe/transport_rule.py +++ b/src/ripe/transport_rule.py @@ -28,7 +28,7 @@ def delete_transport_rule(self, id): contents = self.delete(url) return contents - def resolve_transport_rules( + def resolve_transport_rule( self, brand = None, model = None,