Module: Dipps::Client::Queries

Defined in:
lib/dipps/client/queries.rb,
lib/dipps/client/queries/clients.rb,
lib/dipps/client/queries/create_client.rb,
lib/dipps/client/queries/update_client.rb,
lib/dipps/client/queries/own_invoices_page.rb,
lib/dipps/client/queries/create_own_invoice.rb,
lib/dipps/client/queries/own_credit_notes_page.rb

Constant Summary collapse

Clients =
GraphqlClient.parse <<~GQL
  query($orgNumber: String, $email: String, $freelance_profile_id: ID!) {
    clients(
      orgNumber: $orgNumber,
      email: $email,
      freelanceProfileId: $freelance_profile_id
    ) {
      id
      clientType
      clientNumber
      email
      name
      friendlyName
      orgNumber
      phone
      address {
        line1
        line2
        postalCode
        city
        county
        country
        latitude
        longitude
      }
      referencePeople {
        name
        email
        phone
        referenceNumber
      }
      archivedAt
    }
  }
GQL
CreateClient =
GraphqlClient.parse <<~GQL
  mutation($attributes: CreateClientAttributes!) {
    createClient(
      input: {
        attributes: $attributes
      }
    ) {
      client {
        id
        clientType
        clientNumber
        email
        name
        friendlyName
        orgNumber
        phone
        address {
          line1
          line2
          postalCode
          city
          county
          country
          latitude
          longitude
        }
        referencePeople {
          name
          email
          phone
          referenceNumber
        }
        archivedAt
      }
      errors {
        code
        path
      }
    }
  }
GQL
UpdateClient =
GraphqlClient.parse <<~GQL
  mutation($id: ID!, $attributes: UpdateClientAttributes!) {
    updateClient(
      input: {
        id: $id,
        attributes: $attributes
      }
    ) {
      client {
        id
        clientType
        clientNumber
        email
        name
        friendlyName
        orgNumber
        phone
        address {
          line1
          line2
          postalCode
          city
          county
          country
          latitude
          longitude
        }
        referencePeople {
          name
          email
          phone
          referenceNumber
        }
        archivedAt
      }
      errors {
        code
        path
      }
    }
  }
GQL
OwnInvoicesPage =
GraphqlClient.parse <<~GQL
  query($filter: InvoiceFilters, $sort_by: InvoicesSortByEnum, $page: Int, $per_page: Int) {
    ownInvoicesPage(
      filter: $filter, sortBy: $sort_by, page: $page, perPage: $per_page
    ) {
      collection {
        id
        amount
        buyerReference
        invoiceNumber
        invoicedOn
        orderReference
        pdfDocument {
          filename
          downloadPath
        }
        receiverOrgNumber
        receiverOrgName
        serviceType
        status
        totalAmount
        vat
      }
      _pagination {
        count
        currentPage
        pages
        perPage
      }
    }
  }
GQL
CreateOwnInvoice =
GraphqlClient.parse <<~GQL
  mutation($freelance_profile_id: ID!, $attributes: InvoiceAttributes!) {
    createOwnInvoice(
      input: {
        freelanceProfileId: $freelance_profile_id,
        attributes: $attributes
      }
    ) {
      invoice {
        id
        lines {
          workInvoiceLineId
          workStartedAt
          workEndedAt
          vatRate
          lineType
        }
      }
      errors {
        code
        path
      }
    }
  }
GQL
OwnCreditNotesPage =
GraphqlClient.parse <<~GQL
  query($filter: CreditNotesFilter, $sort_by: CreditNotesSortByEnum, $page: Int, $per_page: Int) {
    ownCreditNotesPage(
      filter: $filter, sortBy: $sort_by, page: $page, perPage: $per_page
    ) {
      collection {
        id
        buyerReference
        creditNoteNumber
        creditedOn
        orderReference
        pdfDocument {
          filename
          downloadPath
        }
        receiverOrgNumber
        receiverOrgName
        serviceType
        status
        totalAmount
        vat
      }
      _pagination {
        count
        currentPage
        pages
        perPage
      }
    }
  }
GQL