From 661254f9a06018fa16304b5f83ffed5ca28bcc46 Mon Sep 17 00:00:00 2001
From: Borja Gimeno <borja.gimeno@somconnexio.coop>
Date: Mon, 17 Apr 2023 12:47:07 +0200
Subject: [PATCH] feat: contracts from odoo with pagination

---
 odoo_somconnexio_python_client/exceptions.py  |   2 +-
 .../resources/contract.py                     |  92 +++++++-------
 .../resources/odoo_paging.py                  |  15 ++-
 ...ntractTests.test_get_contract_by_code.yaml |  45 +++++++
 ...sts.test_get_contract_by_phone_number.yaml |  44 +++++++
 ...actTests.test_search_contract_by_code.yaml |  48 --------
 ....test_search_contract_by_customer_ref.yaml |  56 ---------
 ...tomer_ref_with_pagination_bad_sort_by.yaml |  10 +-
 ....test_search_contract_by_phone_number.yaml |  48 --------
 ...ractTests.test_search_contract_by_vat.yaml |  56 ---------
 ...ch_paginated_contract_by_customer_ref.yaml |  56 ---------
 ...h_paginated_contracts_by_customer_ref.yaml |  84 +++++++++++++
 ...est_search_paginated_contracts_by_vat.yaml |  84 +++++++++++++
 ...tTests.test_search_resource_not_found.yaml |   4 +-
 ...oPackTests.test_search_by_partner_ref.yaml |  51 +++++---
 ...kTests.test_search_resource_not_found.yaml |   2 +-
 tests/resources/test_contract.py              | 113 +++++++++---------
 tests/resources/test_fiber_contracts.py       |  10 +-
 18 files changed, 425 insertions(+), 395 deletions(-)
 create mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_code.yaml
 create mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_phone_number.yaml
 delete mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_code.yaml
 delete mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref.yaml
 delete mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_phone_number.yaml
 delete mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_vat.yaml
 delete mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contract_by_customer_ref.yaml
 create mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_customer_ref.yaml
 create mode 100644 tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_vat.yaml

diff --git a/odoo_somconnexio_python_client/exceptions.py b/odoo_somconnexio_python_client/exceptions.py
index 3372aef..4954f35 100644
--- a/odoo_somconnexio_python_client/exceptions.py
+++ b/odoo_somconnexio_python_client/exceptions.py
@@ -47,7 +47,7 @@ class InvalidSortBy(Exception):
 
 
 class InvalidSortOrder(Exception):
-    message = "Invalid sort order. It must be ASCENDING or DESCENDING"
+    message = "Invalid sort order. It must be ASCENDENT or DESCENDENT"
 
     def __init__(self):
         super(InvalidSortOrder, self).__init__(self.message)
diff --git a/odoo_somconnexio_python_client/resources/contract.py b/odoo_somconnexio_python_client/resources/contract.py
index 5f4e854..18f7037 100644
--- a/odoo_somconnexio_python_client/resources/contract.py
+++ b/odoo_somconnexio_python_client/resources/contract.py
@@ -1,23 +1,21 @@
 from odoo_somconnexio_python_client.client import Client
+from odoo_somconnexio_python_client.resources.address import Address
 from odoo_somconnexio_python_client.resources.odoo_paging import Paging
 
 from ..exceptions import ResourceNotFound
 
+default_limit = 100
+default_offset = 0
+default_sortBy = "id"
+default_sortOrder = "DESCENDENT"
+
 
 class PagingContracts:
-    # TODO: Add all the needed fields in the future...
     def __init__(self, contracts, paging):
         self.contracts = contracts
         self.paging = paging
 
 
-class AddressContract:
-    def __init__(self, **kwargs):
-        self.street = kwargs.get("street")
-        self.zip = kwargs.get("zip")
-        self.city = kwargs.get("city")
-
-
 class Contract:
     _url_path = "/contract"
 
@@ -40,6 +38,12 @@ class Contract:
         date_end,
         is_terminated,
         fiber_signal,
+        description,
+        email,
+        subscription_type,
+        subscription_technology,
+        available_operations,
+        address,
         **kwargs
     ):
         self.id = id
@@ -58,29 +62,34 @@ class Contract:
         self.date_end = date_end
         self.is_terminated = is_terminated
         self.fiber_signal = fiber_signal
-        self.description = kwargs.get("description")
-        self.email = kwargs.get("email")
-        self.subscription_type = kwargs.get("subscription_type")
-        self.subscription_technology = kwargs.get("subscription_technology")
-        self.available_operations = kwargs.get("available_operations")
-        self.address = AddressContract(**kwargs.get("address", {}))
+        self.description = description
+        self.email = email
+        self.subscription_type = subscription_type
+        self.subscription_technology = subscription_technology
+        self.available_operations = available_operations
+        self.address = Address(**address)
 
     @classmethod
-    def paginated_search_by_customer_ref(
-        cls, customer_ref, limit=None, offset=None, sortBy=None, sortOrder=None
+    def search_by_customer_ref(
+        cls,
+        customer_ref,
+        limit=default_limit,
+        offset=default_offset,
+        sortBy=default_sortBy,
+        sortOrder=default_sortOrder,
     ):
         """
         Search Contracts in Odoo by partner's ref and control paging params.
 
-        :return: Contracts object if exists and controls params to pagination
+        :return: Contracts objects if exists and controls params to pagination
         """
         paging = Paging(
-            customer_ref=customer_ref,
             limit=limit,
-            offset=limit,
-            sortOrder=limit,
+            offset=offset,
+            sortBy=sortBy,
+            sortOrder=sortOrder,
         )
-        paging.validate_pagintion()
+        paging.validate_pagination()
         params = {"customer_ref": customer_ref}
         params.update(paging.__dict__)
 
@@ -90,33 +99,36 @@ class Contract:
         )
 
     @classmethod
-    def search_by_customer_ref(cls, customer_ref):
+    def search_by_customer_vat(
+        cls,
+        vat,
+        limit=default_limit,
+        offset=default_offset,
+        sortBy=default_sortBy,
+        sortOrder=default_sortOrder,
+    ):
         """
-        Search Contracts in Odoo by partner's ref.
+        Search Contracts in Odoo by partner's vat and control paging params.
 
-        :return: Contracts object if exists
+        :return: Contracts objects if exists and controls params to pagination
         """
-        return cls._get(
-            params={
-                "customer_ref": customer_ref,
-            },
+        paging = Paging(
+            limit=limit,
+            offset=offset,
+            sortBy=sortBy,
+            sortOrder=sortOrder,
         )
+        paging.validate_pagination()
+        params = {"partner_vat": vat}
+        params.update(paging.__dict__)
 
-    @classmethod
-    def search_by_customer_vat(cls, vat):
-        """
-        Search Contract in Odoo by partner's vat.
-
-        :return: Contract object if exists
-        """
         return cls._get(
-            params={
-                "partner_vat": vat,
-            }
+            params=params,
+            is_paginated=True,
         )
 
     @classmethod
-    def search_by_phone_number(cls, phone_number):
+    def get_by_phone_number(cls, phone_number):
         """
         Search Contract in Odoo by phone number.
 
@@ -129,7 +141,7 @@ class Contract:
         )
 
     @classmethod
-    def search_by_code(cls, code):
+    def get_by_code(cls, code):
         """
         Search Contract in Odoo by code reference.
 
diff --git a/odoo_somconnexio_python_client/resources/odoo_paging.py b/odoo_somconnexio_python_client/resources/odoo_paging.py
index 8b18370..639133f 100644
--- a/odoo_somconnexio_python_client/resources/odoo_paging.py
+++ b/odoo_somconnexio_python_client/resources/odoo_paging.py
@@ -2,25 +2,24 @@ from ..exceptions import (
     InvalidSortOrder,
     NotNumericLimit,
     NotNumericOffset,
-    ResourceNotFound,
 )
 
 
 class Paging:
-    def __init__(self, **kwargs):
-        self.limit = kwargs.get("limit", 10)
-        self.offset = kwargs.get("offset", 0)
-        self.sort_by = kwargs.get("sortBy", "id")
-        self.sort_order = kwargs.get("sortOrder", "DESCENDING")
+    def __init__(self, limit, offset, sortBy, sortOrder, **kwargs):
+        self.limit = limit
+        self.offset = offset
+        self.sortBy = sortBy
+        self.sortOrder = sortOrder
         try:
             self.total_number_records = kwargs["totalNumberOfRecords"]
         except KeyError:
             pass
 
-    def validate_pagintion(self):
+    def validate_pagination(self):
         if not type(self.limit) == int:
             raise NotNumericLimit(limit=self.limit)
         if not type(self.offset) == int:
             raise NotNumericOffset(offset=self.offset)
-        if self.sortOrder not in ["DESCENDING", "ASCENDING"]:
+        if self.sortOrder not in ["DESCENDENT", "ASCENDENT"]:
             raise InvalidSortOrder
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_code.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_code.yaml
new file mode 100644
index 0000000..37df5f3
--- /dev/null
+++ b/tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_code.yaml
@@ -0,0 +1,45 @@
+interactions:
+- request:
+    body: null
+    headers:
+      API-KEY:
+      - DUMMY
+      Accept:
+      - application/json
+      Accept-Encoding:
+      - gzip, deflate
+      Connection:
+      - keep-alive
+      User-Agent:
+      - python-requests/2.27.1
+    method: GET
+    uri: http://odoo-sc.local:8069/api/contract?code=33057
+  response:
+    body:
+      string: '{"contracts": [{"id": 23156, "code": "33057", "email": "yrm9s6wc@caramail.com",
+        "customer_firstname": "Ovidi", "customer_lastname": "Montllor i Mengual",
+        "customer_ref": "27550", "customer_vat": "ES30282588Y", "phone_number": "-",
+        "current_tariff_product": "SE_SC_REC_BA_F_300_SF", "description": "Fibra 300Mb
+        Sense Fix", "ticket_number": "99999994", "technology": "Fiber", "supplier":
+        "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES6621031479773534034515",
+        "is_terminated": false, "date_start": "2021-12-08", "date_end": false, "fiber_signal":
+        "fibraFTTH", "subscription_type": "broad_band", "address": {"street": "Campo
+        Horno, 20", "zip_code": "24946", "city": "Folgoso De La Ribera", "country":
+        "Spain", "state": "Le\u00f3n"}, "subscription_technology": "fiber", "available_operations":
+        []}]}'
+    headers:
+      Content-Length:
+      - '798'
+      Content-Type:
+      - application/json
+      Date:
+      - Mon, 17 Apr 2023 10:14:06 GMT
+      Server:
+      - Werkzeug/0.11.15 Python/3.7.7
+      Set-Cookie:
+      - session_id=3c1ac77bc3adca39b2082391df8505d3baafe316; Expires=Sun, 16-Jul-2023
+        10:14:06 GMT; Max-Age=7776000; HttpOnly; Path=/
+    status:
+      code: 200
+      message: OK
+version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_phone_number.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_phone_number.yaml
new file mode 100644
index 0000000..aa6a768
--- /dev/null
+++ b/tests/resources/cassettes/test_contract/ContractTests.test_get_contract_by_phone_number.yaml
@@ -0,0 +1,44 @@
+interactions:
+- request:
+    body: null
+    headers:
+      API-KEY:
+      - DUMMY
+      Accept:
+      - application/json
+      Accept-Encoding:
+      - gzip, deflate
+      Connection:
+      - keep-alive
+      User-Agent:
+      - python-requests/2.27.1
+    method: GET
+    uri: http://odoo-sc.local:8069/api/contract?phone_number=616904164
+  response:
+    body:
+      string: '{"contracts": [{"id": 23161, "code": "33062", "email": "yrm9s6wc@caramail.com",
+        "customer_firstname": "Ovidi", "customer_lastname": "Montllor i Mengual",
+        "customer_ref": "27550", "customer_vat": "ES30282588Y", "phone_number": "616904164",
+        "current_tariff_product": "SE_SC_REC_MOBILE_T_UNL_5120", "description": "Ilimitadas
+        5 GB", "ticket_number": "99999997", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil",
+        "lang": "ca_ES", "iban": "ES0421004420219290058430", "is_terminated": false,
+        "date_start": "2022-01-14", "date_end": false, "fiber_signal": false, "subscription_type":
+        "mobile", "address": {"street": "-", "zip_code": "-", "city": "-", "country":
+        "Spain", "state": "-"}, "subscription_technology": "mobile", "available_operations":
+        ["ChangeTariffMobile", "AddOneShotMobile"]}]}'
+    headers:
+      Content-Length:
+      - '793'
+      Content-Type:
+      - application/json
+      Date:
+      - Mon, 17 Apr 2023 10:14:06 GMT
+      Server:
+      - Werkzeug/0.11.15 Python/3.7.7
+      Set-Cookie:
+      - session_id=e44885f53c69d50eb43151d21cc1a969185859df; Expires=Sun, 16-Jul-2023
+        10:14:06 GMT; Max-Age=7776000; HttpOnly; Path=/
+    status:
+      code: 200
+      message: OK
+version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_code.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_code.yaml
deleted file mode 100644
index c5b41ab..0000000
--- a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_code.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-interactions:
-  - request:
-      body: null
-      headers:
-        API-KEY:
-          - DUMMY
-        Accept:
-          - application/json
-        Accept-Encoding:
-          - gzip, deflate
-        Connection:
-          - keep-alive
-        User-Agent:
-          - python-requests/2.27.1
-      method: GET
-      uri: http://odoo-sc.local:8069/api/contract?code=78979
-    response:
-      body:
-        string:
-          '{"contracts":[{"id": 59, "code": "78979", "customer_firstname": "Felip", "customer_lastname":
-          "Dara", "customer_ref": "1234", "customer_vat": "ES55642302N", "phone_number":
-          "676858494", "current_tariff_product": "SE_SC_REC_MOBILE_T_150_1024", "ticket_number":
-          "456352563", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil", "lang":
-          "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false, "date_start":
-          "2022-06-14", "date_end": false, "fiber_signal": false,"description":"some description",
-          "email": "xtynl9zrh@lycos.nl","subscription_type":"mobile","subscription_technology":"mobile",
-          "available_operations":["available_operation_1","available_operation_2"],"address":{"street":
-          "some street","zip":"25903","city":"Wisconsin"}}]}'
-      headers:
-        Access-Control-Allow-Methods:
-          - GET
-        Access-Control-Allow-Origin:
-          - None
-        Content-Length:
-          - "442"
-        Content-Type:
-          - application/json
-        Date:
-          - Thu, 16 Jun 2022 10:00:02 GMT
-        Server:
-          - Werkzeug/0.11.15 Python/3.7.7
-        Set-Cookie:
-          - session_id=17c00746057a7e75ceb2b8cdc071edafae33a906; Expires=Wed, 14-Sep-2022
-            10:00:02 GMT; Max-Age=7776000; HttpOnly; Path=/
-      status:
-        code: 200
-        message: OK
-version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref.yaml
deleted file mode 100644
index 0a1cd2a..0000000
--- a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-interactions:
-  - request:
-      body: null
-      headers:
-        API-KEY:
-          - DUMMY
-        Accept:
-          - application/json
-        Accept-Encoding:
-          - gzip, deflate
-        Connection:
-          - keep-alive
-        User-Agent:
-          - python-requests/2.27.1
-      method: GET
-      uri: http://odoo-sc.local:8069/api/contract?customer_ref=123
-    response:
-      body:
-        string:
-          '{"contracts":[{"id": 58, "code": "34636", "customer_firstname": "Felip", "customer_lastname":
-          "Dara", "customer_ref": "123", "customer_vat": "ES55642302N", "phone_number":
-          "879786754", "current_tariff_product": "SE_SC_REC_BA_F_100", "ticket_number":
-          "63636", "technology": "Fiber", "supplier": "M\u00e1sM\u00f3vil", "lang":
-          "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false, "date_start":
-          "2022-05-20", "date_end": false, "fiber_signal": "fibraFTTH","description":"some description",
-          "email": "xtynl9zrh@lycos.nl","subscription_type":"broadband","subscription_technology":"fiber",
-          "available_operations":["available_operation_1","available_operation_2"],
-          "address":{"street":"some street","zip":"25903","city":"Wisconsin"}}, {"id": 59, "code": "78979",
-          "customer_firstname": "Felip", "customer_lastname": "Dara", "customer_ref": "123", "customer_vat":
-          "ES55642302N", "phone_number": "676858494", "current_tariff_product": "SE_SC_REC_MOBILE_T_150_1024",
-          "ticket_number": "456352563", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil",
-          "lang": "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false,
-          "date_start": "2022-06-14", "date_end": false, "fiber_signal": false,"description":"some description",
-          "email": "xtynl9zrh@lycos.nl","subscription_type":"mobile","subscription_technology":"mobile",
-          "available_operations":["available_operation_1","available_operation_2"],
-          "address":{"street":"some street","zip":"25903","city":"Wisconsin"}}]}'
-      headers:
-        Access-Control-Allow-Methods:
-          - GET
-        Access-Control-Allow-Origin:
-          - None
-        Content-Length:
-          - "870"
-        Content-Type:
-          - application/json
-        Date:
-          - Thu, 16 Jun 2022 10:00:02 GMT
-        Server:
-          - Werkzeug/0.11.15 Python/3.7.7
-        Set-Cookie:
-          - session_id=0aca6efbdf9c1e027b5244c5b053eee47a56489a; Expires=Wed, 14-Sep-2022
-            10:00:02 GMT; Max-Age=7776000; HttpOnly; Path=/
-      status:
-        code: 200
-        message: OK
-version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref_with_pagination_bad_sort_by.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref_with_pagination_bad_sort_by.yaml
index 320df13..c59aa64 100644
--- a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref_with_pagination_bad_sort_by.yaml
+++ b/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_customer_ref_with_pagination_bad_sort_by.yaml
@@ -13,21 +13,21 @@ interactions:
       User-Agent:
       - python-requests/2.27.1
     method: GET
-    uri: http://odoo-sc.local:8069/api/contract?customer_ref=123&limit=5&offset=0&sortBy=XXX&sortOrder=DESCENDING
+    uri: http://odoo-sc.local:8069/api/contract?customer_ref=123&limit=5&offset=0&sortBy=XXX&sortOrder=DESCENDENT
   response:
     body:
-      string: '{"code": 400, "name": "Bad Request", "description": "<p>BadRequest Invalid field to SortBy</p>"}'
+      string: '{"code": 400, "name": "Bad Request", "description": "<p>Invalid field
+        to sortBy</p>"}'
     headers:
       Content-Length:
-      - '100'
+      - '85'
       Content-Type:
       - application/json
       Date:
-      - Wed, 19 Jan 2022 09:24:32 GMT
+      - Mon, 17 Apr 2023 10:14:06 GMT
       Server:
       - Werkzeug/0.11.15 Python/3.7.7
     status:
       code: 400
       message: BAD REQUEST
 version: 1
-
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_phone_number.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_phone_number.yaml
deleted file mode 100644
index 194d802..0000000
--- a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_phone_number.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-interactions:
-  - request:
-      body: null
-      headers:
-        API-KEY:
-          - DUMMY
-        Accept:
-          - application/json
-        Accept-Encoding:
-          - gzip, deflate
-        Connection:
-          - keep-alive
-        User-Agent:
-          - python-requests/2.27.1
-      method: GET
-      uri: http://odoo-sc.local:8069/api/contract?phone_number=676858494
-    response:
-      body:
-        string:
-          '{"contracts":[{"id": 59, "code": "78979", "customer_firstname": "Felip", "customer_lastname":
-          "Dara", "customer_ref": "1234", "customer_vat": "ES55642302N", "phone_number":
-          "676858494", "current_tariff_product": "SE_SC_REC_MOBILE_T_150_1024", "ticket_number":
-          "456352563", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil", "lang":
-          "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false, "date_start":
-          "2022-06-14", "date_end": false, "fiber_signal": false,"description":"some description",
-          "email": "xtynl9zrh@lycos.nl","subscription_type":"mobile","subscription_technology":"mobile",
-          "available_operations":["available_operation_1","available_operation_2"],
-          "address":{"street":"some street","zip":"25903","city":"Wisconsin"}}]}'
-      headers:
-        Access-Control-Allow-Methods:
-          - GET
-        Access-Control-Allow-Origin:
-          - None
-        Content-Length:
-          - "442"
-        Content-Type:
-          - application/json
-        Date:
-          - Thu, 16 Jun 2022 10:00:02 GMT
-        Server:
-          - Werkzeug/0.11.15 Python/3.7.7
-        Set-Cookie:
-          - session_id=17c00746057a7e75ceb2b8cdc071edafae33a906; Expires=Wed, 14-Sep-2022
-            10:00:02 GMT; Max-Age=7776000; HttpOnly; Path=/
-      status:
-        code: 200
-        message: OK
-version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_vat.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_vat.yaml
deleted file mode 100644
index 075f5b6..0000000
--- a/tests/resources/cassettes/test_contract/ContractTests.test_search_contract_by_vat.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-interactions:
-  - request:
-      body: null
-      headers:
-        API-KEY:
-          - DUMMY
-        Accept:
-          - application/json
-        Accept-Encoding:
-          - gzip, deflate
-        Connection:
-          - keep-alive
-        User-Agent:
-          - python-requests/2.27.1
-      method: GET
-      uri: http://odoo-sc.local:8069/api/contract?partner_vat=ES55642302N
-    response:
-      body:
-        string:
-          '{"contracts":[{"id": 58, "code": "34636", "customer_firstname": "Felip", "customer_lastname":
-          "Dara", "customer_ref": "1234", "customer_vat": "ES55642302N", "phone_number":
-          "879786754", "current_tariff_product": "SE_SC_REC_BA_F_100", "ticket_number":
-          "63636", "technology": "Fiber", "supplier": "M\u00e1sM\u00f3vil", "lang":
-          "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false, "date_start":
-          "2022-05-20", "date_end": false, "fiber_signal": "fibraFTTH","description":"some description",
-          "email": "xtynl9zrh@lycos.nl","subscription_type":"broadband","subscription_technology":"fiber",
-          "available_operations":["available_operation_1","available_operation_2"],"address":{
-          "street":"some street","zip":"25903","city":"Wisconsin"}}, {"id": 59, "code": "78979",
-          "customer_firstname": "Felip", "customer_lastname": "Dara", "customer_ref": "1234", "customer_vat":
-          "ES55642302N", "phone_number": "676858494", "current_tariff_product": "SE_SC_REC_MOBILE_T_150_1024",
-          "ticket_number": "456352563", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil",
-          "lang": "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false,
-          "date_start": "2022-06-14", "date_end": false, "fiber_signal": false,"description":"some description",
-          "email": "xtynl9zrh@lycos.nl","subscription_type":"mobile","subscription_technology":"mobile",
-          "available_operations":["available_operation_1","available_operation_2"],"address":{"street":"some street",
-          "zip":"25903","city":"Wisconsin"}}]}'
-      headers:
-        Access-Control-Allow-Methods:
-          - GET
-        Access-Control-Allow-Origin:
-          - None
-        Content-Length:
-          - "870"
-        Content-Type:
-          - application/json
-        Date:
-          - Thu, 16 Jun 2022 10:00:02 GMT
-        Server:
-          - Werkzeug/0.11.15 Python/3.7.7
-        Set-Cookie:
-          - session_id=0aca6efbdf9c1e027b5244c5b053eee47a56489a; Expires=Wed, 14-Sep-2022
-            10:00:02 GMT; Max-Age=7776000; HttpOnly; Path=/
-      status:
-        code: 200
-        message: OK
-version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contract_by_customer_ref.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contract_by_customer_ref.yaml
deleted file mode 100644
index 25285f2..0000000
--- a/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contract_by_customer_ref.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-interactions:
-  - request:
-      body: null
-      headers:
-        API-KEY:
-          - DUMMY
-        Accept:
-          - application/json
-        Accept-Encoding:
-          - gzip, deflate
-        Connection:
-          - keep-alive
-        User-Agent:
-          - python-requests/2.27.1
-      method: GET
-      uri: http://odoo-sc.local:8069/api/contract?customer_ref=123&limit=5&offset=0&sortBy=date_start&sortOrder=DESCENDING
-    response:
-      body:
-        string:
-          '{"contracts":[{"id": 58, "code": "34636", "customer_firstname": "Felip", "customer_lastname":
-          "Dara", "customer_ref": "123", "customer_vat": "ES55642302N", "phone_number":
-          "879786754", "current_tariff_product": "SE_SC_REC_BA_F_100", "ticket_number":
-          "63636", "technology": "Fiber", "supplier": "M\u00e1sM\u00f3vil", "lang":
-          "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false, "date_start":
-          "2022-05-20", "date_end": false, "fiber_signal": "fibraFTTH",
-          "description":"some description","email": "xtynl9zrh@lycos.nl","subscription_type":"broadband",
-          "subscription_technology":"fiber","available_operations":["available_operation_1","available_operation_2"],
-          "address":{"street":"some street","zip":"25903","city":"Wisconsin"}}, {"id": 59, "code": "78979",
-          "customer_firstname": "Felip", "customer_lastname": "Dara", "customer_ref": "123", "customer_vat":
-          "ES55642302N", "phone_number": "676858494", "current_tariff_product": "SE_SC_REC_MOBILE_T_150_1024",
-          "ticket_number": "456352563", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil",
-          "lang": "es_ES", "iban": "ES6621000418401234567891", "is_terminated": false,
-          "date_start": "2022-06-14", "date_end": false, "fiber_signal": false,"description":"some description",
-          "email": "xtynl9zrh@lycos.nl","subscription_type":"mobile","subscription_technology":"mobile","available_operations":
-          ["available_operation_1","available_operation_2"],"address":{"street":"some street","zip":"25903","city":"Wisconsin"
-          }}],"paging": {"limit": 5,"totalNumberOfRecords": 5, "offset":0, "sortBy":"date_start", "sortOrder":"DESCENDING"}}'
-      headers:
-        Access-Control-Allow-Methods:
-          - GET
-        Access-Control-Allow-Origin:
-          - None
-        Content-Type:
-          - application/json
-        Content-Length:
-          - "900"
-        Date:
-          - Wed, 08 Mar 2023 07:49:04 GMT
-        Server:
-          - Werkzeug/0.11.15 Python/3.7.7
-        Set-Cookie:
-          - session_id=8a67bcdbd1b9d60e0570ca8d5e38a672a1076e95; Expires=Tue, 06-Jun-2023
-            07:49:04 GMT; Max-Age=7776000; HttpOnly; Path=/
-      status:
-        code: 200
-        message: OK
-version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_customer_ref.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_customer_ref.yaml
new file mode 100644
index 0000000..26fe7a3
--- /dev/null
+++ b/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_customer_ref.yaml
@@ -0,0 +1,84 @@
+interactions:
+- request:
+    body: null
+    headers:
+      API-KEY:
+      - DUMMY
+      Accept:
+      - application/json
+      Accept-Encoding:
+      - gzip, deflate
+      Connection:
+      - keep-alive
+      User-Agent:
+      - python-requests/2.27.1
+    method: GET
+    uri: http://odoo-sc.local:8069/api/contract?customer_ref=27550&limit=5&offset=0&sortBy=code&sortOrder=DESCENDENT
+  response:
+    body:
+      string: '{"contracts": [{"id": 23165, "code": "33066", "email": "yrm9s6wc@caramail.com",
+        "customer_firstname": "Ovidi", "customer_lastname": "Montllor i Mengual",
+        "customer_ref": "27550", "customer_vat": "ES30282588Y", "phone_number": "784203016",
+        "current_tariff_product": "SE_SC_REC_MOBILE_T_150_1024", "description": "150
+        min 1 GB", "ticket_number": "99999998", "technology": "Mobile", "supplier":
+        "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES6621031479773534034515",
+        "is_terminated": false, "date_start": "2022-01-14", "date_end": false, "fiber_signal":
+        false, "subscription_type": "mobile", "address": {"street": "-", "zip_code":
+        "-", "city": "-", "country": "Spain", "state": "-"}, "subscription_technology":
+        "mobile", "available_operations": ["ChangeTariffMobile", "AddOneShotMobile"]},
+        {"id": 23163, "code": "33064", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "717260966", "current_tariff_product":
+        "SE_SC_REC_MOBILE_PACK_UNL_20480", "description": "Il\u00b7limitades 20 GB
+        associat a fibra", "ticket_number": "99999995", "technology": "Mobile", "supplier":
+        "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES6621031479773534034515",
+        "is_terminated": false, "date_start": "2022-01-14", "date_end": false, "fiber_signal":
+        false, "subscription_type": "mobile", "address": {"street": "-", "zip_code":
+        "-", "city": "-", "country": "Spain", "state": "-"}, "subscription_technology":
+        "mobile", "available_operations": ["ChangeTariffMobile", "AddOneShotMobile"]},
+        {"id": 23161, "code": "33062", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "616904164", "current_tariff_product":
+        "SE_SC_REC_MOBILE_T_UNL_5120", "description": "Ilimitadas 5 GB", "ticket_number":
+        "99999997", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil", "lang":
+        "ca_ES", "iban": "ES0421004420219290058430", "is_terminated": false, "date_start":
+        "2022-01-14", "date_end": false, "fiber_signal": false, "subscription_type":
+        "mobile", "address": {"street": "-", "zip_code": "-", "city": "-", "country":
+        "Spain", "state": "-"}, "subscription_technology": "mobile", "available_operations":
+        ["ChangeTariffMobile", "AddOneShotMobile"]}, {"id": 23160, "code": "33061",
+        "email": "yrm9s6wc@caramail.com", "customer_firstname": "Ovidi", "customer_lastname":
+        "Montllor i Mengual", "customer_ref": "27550", "customer_vat": "ES30282588Y",
+        "phone_number": "718559891", "current_tariff_product": "SE_SC_REC_MOBILE_T_UNL_20480",
+        "description": "Ilimitadas 20 GB", "ticket_number": "99999996", "technology":
+        "Mobile", "supplier": "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES0421004420219290058430",
+        "is_terminated": false, "date_start": "2022-01-14", "date_end": false, "fiber_signal":
+        false, "subscription_type": "mobile", "address": {"street": "-", "zip_code":
+        "-", "city": "-", "country": "Spain", "state": "-"}, "subscription_technology":
+        "mobile", "available_operations": ["ChangeTariffMobile", "AddOneShotMobile"]},
+        {"id": 23158, "code": "33059", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "960879143", "current_tariff_product":
+        "SE_SC_REC_BA_F_1024", "description": "Fibra 1Gb", "ticket_number": "99999992",
+        "technology": "Fiber", "supplier": "M\u00e1sM\u00f3vil", "lang": "ca_ES",
+        "iban": "ES0421004420219290058430", "is_terminated": false, "date_start":
+        "2021-12-08", "date_end": false, "fiber_signal": "fibraFTTH", "subscription_type":
+        "broad_band", "address": {"street": "Avenida Horno, 90", "zip_code": "50648",
+        "city": "Contamina", "country": "Spain", "state": "Zaragoza"}, "subscription_technology":
+        "fiber", "available_operations": []}], "paging": {"limit": 5, "offset": 0,
+        "totalNumberOfRecords": 8, "sortBy": "code", "sortOrder": "DESCENDENT"}}'
+    headers:
+      Content-Length:
+      - '4031'
+      Content-Type:
+      - application/json
+      Date:
+      - Mon, 17 Apr 2023 10:14:06 GMT
+      Server:
+      - Werkzeug/0.11.15 Python/3.7.7
+      Set-Cookie:
+      - session_id=a866bd2d33e3e6dee03e632d5006c00cf6ec511c; Expires=Sun, 16-Jul-2023
+        10:14:06 GMT; Max-Age=7776000; HttpOnly; Path=/
+    status:
+      code: 200
+      message: OK
+version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_vat.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_vat.yaml
new file mode 100644
index 0000000..a5d3497
--- /dev/null
+++ b/tests/resources/cassettes/test_contract/ContractTests.test_search_paginated_contracts_by_vat.yaml
@@ -0,0 +1,84 @@
+interactions:
+- request:
+    body: null
+    headers:
+      API-KEY:
+      - DUMMY
+      Accept:
+      - application/json
+      Accept-Encoding:
+      - gzip, deflate
+      Connection:
+      - keep-alive
+      User-Agent:
+      - python-requests/2.27.1
+    method: GET
+    uri: http://odoo-sc.local:8069/api/contract?partner_vat=ES30282588Y&limit=5&offset=0&sortBy=code&sortOrder=DESCENDENT
+  response:
+    body:
+      string: '{"contracts": [{"id": 23165, "code": "33066", "email": "yrm9s6wc@caramail.com",
+        "customer_firstname": "Ovidi", "customer_lastname": "Montllor i Mengual",
+        "customer_ref": "27550", "customer_vat": "ES30282588Y", "phone_number": "784203016",
+        "current_tariff_product": "SE_SC_REC_MOBILE_T_150_1024", "description": "150
+        min 1 GB", "ticket_number": "99999998", "technology": "Mobile", "supplier":
+        "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES6621031479773534034515",
+        "is_terminated": false, "date_start": "2022-01-14", "date_end": false, "fiber_signal":
+        false, "subscription_type": "mobile", "address": {"street": "-", "zip_code":
+        "-", "city": "-", "country": "Spain", "state": "-"}, "subscription_technology":
+        "mobile", "available_operations": ["ChangeTariffMobile", "AddOneShotMobile"]},
+        {"id": 23163, "code": "33064", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "717260966", "current_tariff_product":
+        "SE_SC_REC_MOBILE_PACK_UNL_20480", "description": "Il\u00b7limitades 20 GB
+        associat a fibra", "ticket_number": "99999995", "technology": "Mobile", "supplier":
+        "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES6621031479773534034515",
+        "is_terminated": false, "date_start": "2022-01-14", "date_end": false, "fiber_signal":
+        false, "subscription_type": "mobile", "address": {"street": "-", "zip_code":
+        "-", "city": "-", "country": "Spain", "state": "-"}, "subscription_technology":
+        "mobile", "available_operations": ["ChangeTariffMobile", "AddOneShotMobile"]},
+        {"id": 23161, "code": "33062", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "616904164", "current_tariff_product":
+        "SE_SC_REC_MOBILE_T_UNL_5120", "description": "Ilimitadas 5 GB", "ticket_number":
+        "99999997", "technology": "Mobile", "supplier": "M\u00e1sM\u00f3vil", "lang":
+        "ca_ES", "iban": "ES0421004420219290058430", "is_terminated": false, "date_start":
+        "2022-01-14", "date_end": false, "fiber_signal": false, "subscription_type":
+        "mobile", "address": {"street": "-", "zip_code": "-", "city": "-", "country":
+        "Spain", "state": "-"}, "subscription_technology": "mobile", "available_operations":
+        ["ChangeTariffMobile", "AddOneShotMobile"]}, {"id": 23160, "code": "33061",
+        "email": "yrm9s6wc@caramail.com", "customer_firstname": "Ovidi", "customer_lastname":
+        "Montllor i Mengual", "customer_ref": "27550", "customer_vat": "ES30282588Y",
+        "phone_number": "718559891", "current_tariff_product": "SE_SC_REC_MOBILE_T_UNL_20480",
+        "description": "Ilimitadas 20 GB", "ticket_number": "99999996", "technology":
+        "Mobile", "supplier": "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES0421004420219290058430",
+        "is_terminated": false, "date_start": "2022-01-14", "date_end": false, "fiber_signal":
+        false, "subscription_type": "mobile", "address": {"street": "-", "zip_code":
+        "-", "city": "-", "country": "Spain", "state": "-"}, "subscription_technology":
+        "mobile", "available_operations": ["ChangeTariffMobile", "AddOneShotMobile"]},
+        {"id": 23158, "code": "33059", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "960879143", "current_tariff_product":
+        "SE_SC_REC_BA_F_1024", "description": "Fibra 1Gb", "ticket_number": "99999992",
+        "technology": "Fiber", "supplier": "M\u00e1sM\u00f3vil", "lang": "ca_ES",
+        "iban": "ES0421004420219290058430", "is_terminated": false, "date_start":
+        "2021-12-08", "date_end": false, "fiber_signal": "fibraFTTH", "subscription_type":
+        "broad_band", "address": {"street": "Avenida Horno, 90", "zip_code": "50648",
+        "city": "Contamina", "country": "Spain", "state": "Zaragoza"}, "subscription_technology":
+        "fiber", "available_operations": []}], "paging": {"limit": 5, "offset": 0,
+        "totalNumberOfRecords": 8, "sortBy": "code", "sortOrder": "DESCENDENT"}}'
+    headers:
+      Content-Length:
+      - '4031'
+      Content-Type:
+      - application/json
+      Date:
+      - Mon, 17 Apr 2023 10:14:07 GMT
+      Server:
+      - Werkzeug/0.11.15 Python/3.7.7
+      Set-Cookie:
+      - session_id=5bfe5ebf9c3547abc26713f550b3773dbce5d7bf; Expires=Sun, 16-Jul-2023
+        10:14:07 GMT; Max-Age=7776000; HttpOnly; Path=/
+    status:
+      code: 200
+      message: OK
+version: 1
diff --git a/tests/resources/cassettes/test_contract/ContractTests.test_search_resource_not_found.yaml b/tests/resources/cassettes/test_contract/ContractTests.test_search_resource_not_found.yaml
index 0b54acb..9420197 100644
--- a/tests/resources/cassettes/test_contract/ContractTests.test_search_resource_not_found.yaml
+++ b/tests/resources/cassettes/test_contract/ContractTests.test_search_resource_not_found.yaml
@@ -13,7 +13,7 @@ interactions:
       User-Agent:
       - python-requests/2.27.1
     method: GET
-    uri: http://odoo-sc.local:8069/api/contract?partner_vat=ES3208282S
+    uri: http://odoo-sc.local:8069/api/contract?phone_number=9999
   response:
     body:
       string: '{"code": 404, "name": "Not Found"}'
@@ -23,7 +23,7 @@ interactions:
       Content-Type:
       - application/json
       Date:
-      - Thu, 16 Jun 2022 10:00:02 GMT
+      - Mon, 17 Apr 2023 10:14:07 GMT
       Server:
       - Werkzeug/0.11.15 Python/3.7.7
     status:
diff --git a/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_by_partner_ref.yaml b/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_by_partner_ref.yaml
index 84c2f34..bc91c17 100644
--- a/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_by_partner_ref.yaml
+++ b/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_by_partner_ref.yaml
@@ -13,29 +13,50 @@ interactions:
       User-Agent:
       - python-requests/2.27.1
     method: GET
-    uri: http://odoo-sc.local:8069/api/contract/available-fibers-to-link-with-mobile?partner_ref=123
+    uri: http://odoo-sc.local:8069/api/contract/available-fibers-to-link-with-mobile?partner_ref=27550
   response:
     body:
-      string: '[{"id": 123,"code": "123","customer_firstname": "Angel","customer_lastname": "Cristo, Papadopulos","customer_ref": "123",
-    "customer_vat": "ES74765579P","phone_number": "957909026","current_tariff_product": "SE_SC_REC_BA_F_100_SF","ticket_number": false,
-    "technology": "Fiber","supplier": "Vodafone","lang": "ca_ES","iban": "ES9420481458149528653586","is_terminated": false,
-    "date_start": "2018-05-18","date_end": false,"fiber_signal": false}]'
+      string: '[{"id": 23154, "code": "33055", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "939591019", "current_tariff_product":
+        "SE_SC_REC_BA_F_600", "description": "Fibra 600Mb", "ticket_number": "99999991",
+        "technology": "Fiber", "supplier": "M\u00e1sM\u00f3vil", "lang": "ca_ES",
+        "iban": "ES6621031479773534034515", "is_terminated": false, "date_start":
+        "2021-12-08", "date_end": false, "fiber_signal": "fibraFTTH", "subscription_type":
+        "broad_band", "address": {"street": "Ronda Horno, 4", "zip_code": "41202",
+        "city": "Umbrete", "country": "Spain", "state": "Sevilla"}, "subscription_technology":
+        "fiber", "available_operations": []}, {"id": 23155, "code": "33056", "email":
+        "yrm9s6wc@caramail.com", "customer_firstname": "Ovidi", "customer_lastname":
+        "Montllor i Mengual", "customer_ref": "27550", "customer_vat": "ES30282588Y",
+        "phone_number": "953777554", "current_tariff_product": "SE_SC_REC_BA_F_300",
+        "description": "Fibra 300Mb", "ticket_number": "99999993", "technology": "Fiber",
+        "supplier": "M\u00e1sM\u00f3vil", "lang": "ca_ES", "iban": "ES0421004420219290058430",
+        "is_terminated": false, "date_start": "2021-12-08", "date_end": false, "fiber_signal":
+        "fibraFTTH", "subscription_type": "broad_band", "address": {"street": "Avinguda
+        Mayor, 9", "zip_code": "45218", "city": "Hontanar", "country": "Spain", "state":
+        "Toledo"}, "subscription_technology": "fiber", "available_operations": []},
+        {"id": 23158, "code": "33059", "email": "yrm9s6wc@caramail.com", "customer_firstname":
+        "Ovidi", "customer_lastname": "Montllor i Mengual", "customer_ref": "27550",
+        "customer_vat": "ES30282588Y", "phone_number": "960879143", "current_tariff_product":
+        "SE_SC_REC_BA_F_1024", "description": "Fibra 1Gb", "ticket_number": "99999992",
+        "technology": "Fiber", "supplier": "M\u00e1sM\u00f3vil", "lang": "ca_ES",
+        "iban": "ES0421004420219290058430", "is_terminated": false, "date_start":
+        "2021-12-08", "date_end": false, "fiber_signal": "fibraFTTH", "subscription_type":
+        "broad_band", "address": {"street": "Avenida Horno, 90", "zip_code": "50648",
+        "city": "Contamina", "country": "Spain", "state": "Zaragoza"}, "subscription_technology":
+        "fiber", "available_operations": []}]'
     headers:
-      Access-Control-Allow-Methods:
-        - GET
-      Access-Control-Allow-Origin:
-        - None
       Content-Length:
-        - "650"
+      - '2294'
       Content-Type:
-        - application/json
+      - application/json
       Date:
-      - Wed, 08 Mar 2023 16:51:05 GMT
+      - Mon, 17 Apr 2023 10:38:05 GMT
       Server:
-        - Werkzeug/0.11.15 Python/3.7.7
+      - Werkzeug/0.11.15 Python/3.7.7
       Set-Cookie:
-      - session_id=73f9c9eae62ce1a9dd1008c0e463e79f7f3295d8; Expires=Tue, 06-Jun-2023
-        16:51:05 GMT; Max-Age=7776000; HttpOnly; Path=/
+      - session_id=dcc083bd607a8ce229819ea899c59a3861970478; Expires=Sun, 16-Jul-2023
+        10:38:05 GMT; Max-Age=7776000; HttpOnly; Path=/
     status:
       code: 200
       message: OK
diff --git a/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_resource_not_found.yaml b/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_resource_not_found.yaml
index cfb5336..53090bb 100644
--- a/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_resource_not_found.yaml
+++ b/tests/resources/cassettes/test_fiber_contracts/FiberContractsToPackTests.test_search_resource_not_found.yaml
@@ -23,7 +23,7 @@ interactions:
       Content-Type:
       - application/json
       Date:
-      - Wed, 08 Mar 2023 16:51:05 GMT
+      - Mon, 17 Apr 2023 10:38:05 GMT
       Server:
       - Werkzeug/0.11.15 Python/3.7.7
     status:
diff --git a/tests/resources/test_contract.py b/tests/resources/test_contract.py
index 9b2267c..f5a3beb 100644
--- a/tests/resources/test_contract.py
+++ b/tests/resources/test_contract.py
@@ -27,82 +27,87 @@ class ContractTests(unittest.TestCase):
     @pytest.mark.vcr()
     def test_search_resource_not_found(self):
         self.assertRaises(
-            ResourceNotFound, Contract.search_by_customer_vat, vat="ES3208282S"
+            ResourceNotFound, Contract.get_by_phone_number, phone_number="9999"
         )
 
     @pytest.mark.vcr()
-    def test_search_contract_by_vat(self):
-        contracts = Contract.search_by_customer_vat(vat="ES55642302N")
-        first_contract = contracts[0]
-        second_contract = contracts[1]
-
-        assert first_contract.code == "34636"
-        assert first_contract.customer_vat == "ES55642302N"
-        assert first_contract.phone_number == "879786754"
-        assert first_contract.current_tariff_product == "SE_SC_REC_BA_F_100"
-
-        assert second_contract.code == "78979"
-        assert second_contract.customer_vat == "ES55642302N"
-        assert second_contract.phone_number == "676858494"
-        assert second_contract.current_tariff_product == "SE_SC_REC_MOBILE_T_150_1024"
-
-    @pytest.mark.vcr()
-    def test_search_contract_by_phone_number(self):
-        contracts = Contract.search_by_phone_number(phone_number="676858494")
+    def test_get_contract_by_phone_number(self):
+        contracts = Contract.get_by_phone_number(phone_number="616904164")
         contract = contracts[0]
 
-        assert contract.code == "78979"
-        assert contract.customer_vat == "ES55642302N"
-        assert contract.phone_number == "676858494"
-        assert contract.current_tariff_product == "SE_SC_REC_MOBILE_T_150_1024"
+        assert contract.code == "33062"
+        assert contract.customer_vat == "ES30282588Y"
+        assert contract.phone_number == "616904164"
+        assert contract.current_tariff_product == "SE_SC_REC_MOBILE_T_UNL_5120"
 
     @pytest.mark.vcr()
-    def test_search_contract_by_code(self):
-        contracts = Contract.search_by_code(code="78979")
+    def test_get_contract_by_code(self):
+        contracts = Contract.get_by_code(code="33057")
         contract = contracts[0]
 
-        assert contract.code == "78979"
-        assert contract.customer_vat == "ES55642302N"
-        assert contract.phone_number == "676858494"
-        assert contract.current_tariff_product == "SE_SC_REC_MOBILE_T_150_1024"
+        assert contract.code == "33057"
+        assert contract.customer_vat == "ES30282588Y"
+        assert contract.phone_number == "-"
+        assert contract.current_tariff_product == "SE_SC_REC_BA_F_300_SF"
 
     @pytest.mark.vcr()
-    def test_search_contract_by_customer_ref(self):
-        contracts = Contract.search_by_customer_ref(customer_ref="123")
-        contract = contracts[0]
+    def test_search_paginated_contracts_by_customer_ref(self):
+        paging_contracts = Contract.search_by_customer_ref(
+            customer_ref="27550",
+            limit=5,
+            offset=0,
+            sortBy="code",
+            sortOrder="DESCENDENT",
+        )
+        contract = paging_contracts.contracts[1]
+        paging = paging_contracts.paging
 
-        assert contract.customer_ref == "123"
-        assert contract.customer_vat == "ES55642302N"
-        assert contract.phone_number == "879786754"
-        assert contract.current_tariff_product == "SE_SC_REC_BA_F_100"
+        assert contract.customer_ref == "27550"
+        assert contract.customer_vat == "ES30282588Y"
+        assert contract.phone_number == "717260966"
+        assert contract.current_tariff_product == "SE_SC_REC_MOBILE_PACK_UNL_20480"
+        assert paging.limit == 5
+        assert paging.total_number_records == 8
+        assert paging.offset == 0
+        assert paging.sortBy == "code"
+        assert paging.sortOrder == "DESCENDENT"
 
     @pytest.mark.vcr()
-    def test_search_paginated_contract_by_customer_ref(self):
-        paging_contracts = Contract.paginated_search_by_customer_ref(
-            customer_ref="123",
+    def test_search_paginated_contracts_by_vat(self):
+        paging_contracts = Contract.search_by_customer_vat(
+            vat="ES30282588Y",
             limit=5,
             offset=0,
-            sortBy="date_start",
-            sortOrder="DESCENDING",
+            sortBy="code",
+            sortOrder="DESCENDENT",
         )
-        contract = paging_contracts.contracts[1]
         paging = paging_contracts.paging
+        first_contract = paging_contracts.contracts[0]
+        second_contract = paging_contracts.contracts[1]
+
+        assert first_contract.code == "33066"
+        assert first_contract.customer_vat == "ES30282588Y"
+        assert first_contract.phone_number == "784203016"
+        assert first_contract.current_tariff_product == "SE_SC_REC_MOBILE_T_150_1024"
+
+        assert second_contract.code == "33064"
+        assert second_contract.customer_vat == "ES30282588Y"
+        assert second_contract.phone_number == "717260966"
+        assert (
+            second_contract.current_tariff_product == "SE_SC_REC_MOBILE_PACK_UNL_20480"
+        )
 
-        assert contract.customer_ref == "123"
-        assert contract.customer_vat == "ES55642302N"
-        assert contract.phone_number == "676858494"
-        assert contract.current_tariff_product == "SE_SC_REC_MOBILE_T_150_1024"
         assert paging.limit == 5
-        assert paging.total_number_records == 5
+        assert paging.total_number_records == 8
         assert paging.offset == 0
-        assert paging.sort_by == "date_start"
-        assert paging.sort_order == "DESCENDING"
+        assert paging.sortBy == "code"
+        assert paging.sortOrder == "DESCENDENT"
 
     @pytest.mark.vcr()
     def test_search_contract_by_customer_ref_with_pagination_bad_limit(self):
         self.assertRaises(
             NotNumericLimit,
-            Contract.paginated_search_by_customer_ref,
+            Contract.search_by_customer_ref,
             customer_ref="123",
             limit="XXX",
         )
@@ -111,7 +116,7 @@ class ContractTests(unittest.TestCase):
     def test_search_contract_by_customer_ref_with_pagination_bad_offset(self):
         self.assertRaises(
             NotNumericOffset,
-            Contract.paginated_search_by_customer_ref,
+            Contract.search_by_customer_ref,
             customer_ref="123",
             limit=5,
             offset="XXX",
@@ -121,7 +126,7 @@ class ContractTests(unittest.TestCase):
     def test_search_contract_by_customer_ref_with_pagination_bad_sort_order(self):
         self.assertRaises(
             InvalidSortOrder,
-            Contract.paginated_search_by_customer_ref,
+            Contract.search_by_customer_ref,
             customer_ref="123",
             limit=5,
             offset=0,
@@ -133,10 +138,10 @@ class ContractTests(unittest.TestCase):
     def test_search_contract_by_customer_ref_with_pagination_bad_sort_by(self):
         self.assertRaises(
             InvalidSortBy,
-            Contract.paginated_search_by_customer_ref,
+            Contract.search_by_customer_ref,
             customer_ref="123",
             limit=5,
             offset=0,
             sortBy="XXX",
-            sortOrder="DESCENDING",
+            sortOrder="DESCENDENT",
         )
diff --git a/tests/resources/test_fiber_contracts.py b/tests/resources/test_fiber_contracts.py
index 1c2628a..5e5a4f4 100644
--- a/tests/resources/test_fiber_contracts.py
+++ b/tests/resources/test_fiber_contracts.py
@@ -18,13 +18,13 @@ def vcr_config():
 class FiberContractsToPackTests(unittest.TestCase):
     @pytest.mark.vcr()
     def test_search_by_partner_ref(self):
-        contracts = FiberContractsToPack.search_by_partner_ref(partner_ref=123)
+        contracts = FiberContractsToPack.search_by_partner_ref(partner_ref=27550)
         contract = contracts[0]
 
-        assert contract.code == "123"
-        assert contract.customer_vat == "ES74765579P"
-        assert contract.phone_number == "957909026"
-        assert contract.current_tariff_product == "SE_SC_REC_BA_F_100_SF"
+        assert contract.code == "33055"
+        assert contract.customer_vat == "ES30282588Y"
+        assert contract.phone_number == "939591019"
+        assert contract.current_tariff_product == "SE_SC_REC_BA_F_600"
 
     @pytest.mark.vcr()
     def test_search_resource_not_found(self):
-- 
GitLab