Giter Club home page Giter Club logo

sevdesk's Introduction

sevDesk GO Lang

With this small library we want to simplify the handling of the sevDesk Api. Currently you can only create invoices and add invoices via ID single positions.

Install

go get github.com/gowizzard/sevdesk

How to use?

You can currently only create invoices and items in the invoices. For this purpose, sevDesk provides some parameters that are currently not well documented.

Get invoices

It is now possible to read out the invoices. This is done in a very simple way. You use the following function with your user token and get back an object with slices.

invoices, err := sevdesk.Invoices("token")
if err != nil {
fmt.Println("Error: ", err)
}

fmt.Println(invoices)

Create invoice

Here you will find an example how to create a new invoice in sevDesk.

invoice, err := sevdesk.NewInvoice(sevdesk.Invoice{"contactID", "address", "invoiceDate", "status", "invoiceType", "contactPerson", "subject", "headText", "footText", "token"})
if err != nil {
    fmt.Println("Error: ", err)
}
	
// Return the invoice id
fmt.Println(invoice.Objects.ID)

Create new position in an invoice

Here is an example how to create a new position in an existing invoice.You need the ID of the invoice and of course the contact ID. You also need the parameter that distinguishes between pcs, hours or %.

For this I have worked it all out as follows. The funny thing is that the ID does not start with 0 but with 1:

1 = Stk, 2 = m², 3 = m, 4 = kg, 5 = t, 6 = lfm, 7 = pauschal, 8 = m³, 9 = Std, 10 = km, 11 = %, 12 = Tag(e), 13 = l

In sevDesk the price is transferred in gross, therefore we have added a calculation of the gross value to the function. So you set the net value + the VAT in the function.

position, err := sevdesk.NewPosition(sevdesk.Position{"45", "1", "16", "Backups", "Backups of all Websites", "9", "invoiceID", "token"})
if err != nil {
    fmt.Println("Error: ", err)
}

// Return the invoice id
fmt.Println(position.Objects.ID)

Send invoice via email

So that you can send your invoices directly there is now a new function. You can adjust several parameters like email, CC, BCC, subject and a text.

When using this function, an email is sent directly to the specified email address and the invoice is attached as a PDF.

// Send email
email, err := sevdesk.SendInvoiceEmail(sevdesk.InvoiceEmail{invoice.Objects.ID, "email", "subject", "text", "cc", "bcc", "token"})
if err != nil {
    fmt.Println(err)
}

Send invoice for download

In order to download an invoice, the status must first be changed to sent. You can do this with the following function.

sendInvoice, err := sevdesk.SendInvoicePDF(sevdesk.SendInvoice{invoice.Objects.ID, "VPDF", "false", "token"})
if err != nil {
fmt.Println(err)
}

Downlaod invoice

When the invoice has been marked as sent, it can be downloaded. The data will be returned as bytes.

download, err := sevdesk.DownloadInvoicePDF(sevdesk.DownloadInvoice{invoice.Objects.ID, "true", "true", "token"})
if err != nil {
    fmt.Println(err)
}

Get contacts

If you want to read out all customers, then it goes as follows:

contacts, err := sevdesk.Contacts("token")
if err != nil {
	fmt.Println("Error: ", err)
}

Set new contact

If you want to set a new Contact, then this goes as follows. Some attributes are needed for this. The category[id] must be set. The best is a 3. Otherwise the other fields are free. The token must be specified of course.

contact, err := sevdesk.NewContact(sevdesk.Contact{"Name", "Name2", "Surname", "Familyname", "Vat number", "Tax number", "Bank account", "Bank number", "CategoryID", "token"})
if err != nil {
	fmt.Println("Error: ", err)
}

Add information

For each newly created contact, additional information about the contact can be added. Like an email, a phone number or a website. The CategorieID is very important. You can find it here.

The key represents what type it is (1: Private, 2: Work, 3. Fax, 4. Mobil, 5. empty, 6. Autobox, 7. Newsletter, 8. Invoice address)

Add address

If you want to add an address, this is how to do it:

address, err := sevdesk.NewAddress(sevdesk.Address{"Street", "Zip", "City", "ContactID", "Token"})
if err != nil {
	fmt.Println("Error: ", err)
}

Add email

If you want to add an email, then this goes as follows:

email, err := sevdesk.NewEmail(sevdesk.Communication{"Key", "Value", "ContactID", "Token"})
if err != nil {
    fmt.Println("Error: ", err)
}

Add phone

If you want to add a phone number, this is how to do it:

phone, err := sevdesk.NewPhone(sevdesk.Communication{"Key", "Value", "ContactID", "Token"})
if err != nil {
    fmt.Println("Error: ", err)
}

Add mobile

If you want to add a mobile number, this is how to do it:

mobile, err := sevdesk.NewMobile(sevdesk.Communication{"Key", "Value", "ContactID", "Token"})
if err != nil {
    fmt.Println("Error: ", err)
}

Add website

If you want to add a website, this is how to do it:

website, err := sevdesk.NewWebsite(sevdesk.Communication{"Key", "Value", "ContactID", "Token"})
if err != nil {
    fmt.Println("Error: ", err)
}

Help

If you have any questions or comments, please contact us by e-mail at [email protected]

sevdesk's People

Contributors

gowizzard avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

sevdesk's Issues

sevDesk contact & contactPerson

Hi,
just stumbled upon your nice project as I currently implementing a similar Python service 😄 .
I was wondering if you guys found a way to automatically retrieve the contactPerson information from sevDesk - the one of the form:

 "contactPerson": {
      "id": "xyz",
      "objectName": "SevUser"
  }

Cheers, Luca

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.