# Path: netvisor/requests/sales_invoice.py
# class CreateSalesInvoiceRequest(Request):
#     method = 'POST'
#     uri = 'salesinvoice.nv'
#     response_cls = CreateSalesInvoiceResponse
#     schema_cls = CreateSalesInvoiceSchema
#     tag_name = 'sales_invoice'
# 
# class GetSalesInvoiceRequest(Request):
#     method = 'GET'
#     uri = 'GetSalesInvoice.nv'
#     response_cls = GetSalesInvoiceResponse
# 
#     def parse_response(self, response):
#         data = super(GetSalesInvoiceRequest, self).parse_response(response)
#         self.ensure_not_empty(data)
#         return data
# 
#     def ensure_not_empty(self, data):
#         if data is None:
#             raise InvalidData(
#                 'Data form incorrect:. '
#                 'Sales invoice not found with Netvisor identifier: {0}'.format(
#                     self.params['NetvisorKey']
#                 )
#             )
# 
# class SalesInvoiceListRequest(Request):
#     method = 'GET'
#     uri = 'SalesInvoiceList.nv'
#     response_cls = SalesInvoiceListResponse
# 
# class UpdateSalesInvoiceRequest(Request):
#     method = 'POST'
#     uri = 'salesinvoice.nv'
#     response_cls = UpdateSalesInvoiceResponse
#     schema_cls = CreateSalesInvoiceSchema
#     tag_name = 'sales_invoice'
# 
# Path: netvisor/services/base.py
# class Service(object):
#     def __init__(self, client):
#         self.client = client


from ..requests.sales_invoice import (
    CreateSalesInvoiceRequest,
    GetSalesInvoiceRequest,
    SalesInvoiceListRequest,
    UpdateSalesInvoiceRequest
)
from .base import Service
# -*- coding: utf-8 -*-
"""
    netvisor.services.sales_invoice
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: (c) 2013-2016 by Fast Monkeys Oy.
    :license: MIT, see LICENSE for more details.
"""


class SalesInvoiceService(Service):
    def get(self, id):
        request = GetSalesInvoiceRequest(
            self.client,
            params={'NetvisorKey': id}
        )
        return request.make_request()

    def list(self, above_id=None, invoice_number=None):
        request = SalesInvoiceListRequest(
            self.client,
            params={
                'InvoicesAboveNetvisorKey': above_id,
                'InvoiceNumber': invoice_number
            }
        )
        return request.make_request()

    def create(self, data):

# Path: netvisor/requests/sales_invoice.py
# class CreateSalesInvoiceRequest(Request):
#     method = 'POST'
#     uri = 'salesinvoice.nv'
#     response_cls = CreateSalesInvoiceResponse
#     schema_cls = CreateSalesInvoiceSchema
#     tag_name = 'sales_invoice'
# 
# class GetSalesInvoiceRequest(Request):
#     method = 'GET'
#     uri = 'GetSalesInvoice.nv'
#     response_cls = GetSalesInvoiceResponse
# 
#     def parse_response(self, response):
#         data = super(GetSalesInvoiceRequest, self).parse_response(response)
#         self.ensure_not_empty(data)
#         return data
# 
#     def ensure_not_empty(self, data):
#         if data is None:
#             raise InvalidData(
#                 'Data form incorrect:. '
#                 'Sales invoice not found with Netvisor identifier: {0}'.format(
#                     self.params['NetvisorKey']
#                 )
#             )
# 
# class SalesInvoiceListRequest(Request):
#     method = 'GET'
#     uri = 'SalesInvoiceList.nv'
#     response_cls = SalesInvoiceListResponse
# 
# class UpdateSalesInvoiceRequest(Request):
#     method = 'POST'
#     uri = 'salesinvoice.nv'
#     response_cls = UpdateSalesInvoiceResponse
#     schema_cls = CreateSalesInvoiceSchema
#     tag_name = 'sales_invoice'
# 
# Path: netvisor/services/base.py
# class Service(object):
#     def __init__(self, client):
#         self.client = client


# Path: netvisor/services/sales_invoice.py
from ..requests.sales_invoice import (
    CreateSalesInvoiceRequest,
    GetSalesInvoiceRequest,
    SalesInvoiceListRequest,
    UpdateSalesInvoiceRequest
)
from .base import Service

# -*- coding: utf-8 -*-
"""
    netvisor.services.sales_invoice
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: (c) 2013-2016 by Fast Monkeys Oy.
    :license: MIT, see LICENSE for more details.
"""


class SalesInvoiceService(Service):
    def get(self, id):
        request = GetSalesInvoiceRequest(
            self.client,
            params={'NetvisorKey': id}
        )
        return request.make_request()

    def list(self, above_id=None, invoice_number=None):
        request = SalesInvoiceListRequest(
            self.client,
            params={
                'InvoicesAboveNetvisorKey': above_id,
                'InvoiceNumber': invoice_number
            }
        )
        return request.make_request()

    def create(self, data):

        request = CreateSalesInvoiceRequest(