// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.27.0
// source: organization.sql

package sqlite

import (
	"context"
	"time"
)

const createOrganization = `-- name: CreateOrganization :one
INSERT INTO organization
    (name, owner_name, owner_phone, owner_email, created_at, deleted_at, authorized, auth_token)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING id, name, owner_name, owner_phone, owner_email, created_at, deleted_at, authorized, auth_token
`

type CreateOrganizationParams struct {
	Name       string     `db:"name" json:"name"`
	OwnerName  string     `db:"owner_name" json:"owner_name"`
	OwnerPhone string     `db:"owner_phone" json:"owner_phone"`
	OwnerEmail string     `db:"owner_email" json:"owner_email"`
	CreatedAt  *time.Time `db:"created_at" json:"created_at"`
	DeletedAt  *time.Time `db:"deleted_at" json:"deleted_at"`
	Authorized int64      `db:"authorized" json:"authorized"`
	AuthToken  string     `db:"auth_token" json:"auth_token"`
}

func (q *Queries) CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Organization, error) {
	row := q.db.QueryRowContext(ctx, createOrganization,
		arg.Name,
		arg.OwnerName,
		arg.OwnerPhone,
		arg.OwnerEmail,
		arg.CreatedAt,
		arg.DeletedAt,
		arg.Authorized,
		arg.AuthToken,
	)
	var i Organization
	err := row.Scan(
		&i.Identifier,
		&i.Name,
		&i.OwnerName,
		&i.OwnerPhone,
		&i.OwnerEmail,
		&i.CreatedAt,
		&i.DeletedAt,
		&i.Authorized,
		&i.AuthToken,
	)
	return i, err
}

const findOrganizationById = `-- name: FindOrganizationById :one
SELECT id, name, owner_name, owner_phone, owner_email, created_at, deleted_at, authorized, auth_token FROM organization
WHERE id = ?
`

func (q *Queries) FindOrganizationById(ctx context.Context, id int64) (Organization, error) {
	row := q.db.QueryRowContext(ctx, findOrganizationById, id)
	var i Organization
	err := row.Scan(
		&i.Identifier,
		&i.Name,
		&i.OwnerName,
		&i.OwnerPhone,
		&i.OwnerEmail,
		&i.CreatedAt,
		&i.DeletedAt,
		&i.Authorized,
		&i.AuthToken,
	)
	return i, err
}

const findOrganizationByName = `-- name: FindOrganizationByName :one
SELECT id, name, owner_name, owner_phone, owner_email, created_at, deleted_at, authorized, auth_token FROM organization
WHERE name = ?
`

func (q *Queries) FindOrganizationByName(ctx context.Context, name string) (Organization, error) {
	row := q.db.QueryRowContext(ctx, findOrganizationByName, name)
	var i Organization
	err := row.Scan(
		&i.Identifier,
		&i.Name,
		&i.OwnerName,
		&i.OwnerPhone,
		&i.OwnerEmail,
		&i.CreatedAt,
		&i.DeletedAt,
		&i.Authorized,
		&i.AuthToken,
	)
	return i, err
}
