bcccoreapi

package
v0.2.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAgent = fmt.Sprintf("Go-BCCCoreApi/%s", Version)
View Source
var Version = "0.2.0-alpha"

Functions

This section is empty.

Types

type Client

type Client struct {
	Affiliation    *genericClient[models.Affiliation, models.AffiliationWrite]
	Consent        *genericClient[models.Consent, models.ConsentWrite]
	Country        *genericClient[models.Country, models.CountryWrite]
	Group          *groupClient
	Org            *genericClient[models.Org, models.OrgWrite]
	Person         *genericClient[models.Person, models.PersonWrite]
	Relation       *genericClient[models.Relation, models.RelationWrite]
	RoleAssignment *genericClient[models.RoleAssignment, models.RoleAssignmentWrite]
	Role           *genericClient[models.Role, models.RoleWrite]
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...ClientOption) *Client

func (*Client) Do

func (m *Client) Do(req *http.Request) (*http.Response, error)

Do triggers an HTTP request and returns an HTTP response, handling any context cancellations or timeouts.

func (*Client) NewRequest

func (c *Client) NewRequest(
	ctx context.Context,
	method,
	uri string,
	payload any,
	options ...RequestOption,
) (*http.Request, error)

func (*Client) RefreshTestData

func (c *Client) RefreshTestData() error

Resets test data, only available if the SDK is run against the emulator

func (*Client) Request

func (m *Client) Request(ctx context.Context, method, uri string, payload any, result any, options ...RequestOption) error

Request combines NewRequest and Do, while also handling decoding of response payload.

Can be used to provide a custom payload type for a request

func (*Client) URL

func (c *Client) URL(parts ...string) string

Joins provided url parts with the base url to build the endpoint for calling

type ClientOption

type ClientOption func(*Client)

func WithClientCredentials

func WithClientCredentials(ctx context.Context, clientID, clientSecret string, scopes ...Scope) ClientOption

WithClientCredentials configures the SDK to authenticate using the client credentials authentication flow.

func WithCustomEnvironment

func WithCustomEnvironment(envConfig EnvironmentConfig) ClientOption

WithCustomEnvironment sets a custom environment config for the SDK to use. Can be used to if you want to pass your requests thorugh a proxy, or to connect to an emulator

func WithEmulator

func WithEmulator(ctx context.Context, envConfig EnvironmentConfig, scopes ...Scope) ClientOption

WithEmulator configures the SDK to authenticate using the client credentials authentication flow against the emulator.

func WithEnvironment

func WithEnvironment(env Environment) ClientOption

WithEnvironment configures the SDK to override the used environment (by default Prod is used)

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

WithHTTPClient configures the SDK to use the provided HTTP client.

func WithStaticToken

func WithStaticToken(token string) ClientOption

WithStaticToken configures the SDK to authenticate using the provided token

func WithTokenSource

func WithTokenSource(tokenSource oauth2.TokenSource) ClientOption

WithTokenSource configures the SDK to authenticate using the provided token source

type Environment

type Environment int
const (
	EnvironmentProd Environment = iota
	EnvironmentSandbox
	EnvironmentDev
)

type EnvironmentConfig

type EnvironmentConfig struct {
	BaseUrl  string
	TokenUrl string
	Audience string
}

type Error

type Error struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
}

func (*Error) Error

func (m *Error) Error() string

Error formats the error into a string representation.

type ErrorCode

type ErrorCode string
const (
	ErrorCodeNotFound             ErrorCode = "not-found"
	ErrorCodeInvalidQuery         ErrorCode = "invalid-query"
	ErrorCodeInvalidBody          ErrorCode = "invalid-body"
	ErrorCodeInvalidKeyReference  ErrorCode = "invalid-key-reference"
	ErrorCodeDuplicateUniqueKey   ErrorCode = "duplicate-unique-key"
	ErrorCodeCannotParseToken     ErrorCode = "cannot-parse-token"
	ErrorCodeInvalidToken         ErrorCode = "invalid-token"
	ErrorCodeMissingScopes        ErrorCode = "missing-scopes"
	ErrorCodeInternalError        ErrorCode = "internal-error"
	ErrorCodeUnauthorized         ErrorCode = "unauthorized"
	ErrorCodeInvalidAppUID        ErrorCode = "invalid-app-uid"
	ErrorCodeUnknownErrorResponse ErrorCode = "unknown-error-response"
)

type QueryOpts

type QueryOpts struct {
	IncludePersonsWithoutChurchAffiliation bool     `json:"includePersonsWithoutChurchAffiliation"`
	IncludeInactive                        []string `json:"includeInactive"`
	OrgUIDs                                []uuid.UUID
}

type RequestOption

type RequestOption func(*http.Request)

func Fields

func Fields(fields ...string) RequestOption

Fields allows to specify the fields returned by the SDK See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#fields Works for Find and Get endpoints

func Filter

func Filter(filter string) RequestOption

Filter the result based on the provided condition See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#filter Only works for Find endpoints

func Limit

func Limit(n int) RequestOption

Limit will restrict the number of returned results to n See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#limit Only works for Find endpoints

func Page

func Page(n int) RequestOption

Skip will skip the first (n - 1) * Limit rows from the results See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#page Only works for Find endpoints

func QueryOptions

func QueryOptions(q QueryOpts) RequestOption

Sets additional query options See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#options Works for Find and Get endpoints

func Search(s string) RequestOption

Performs a fuzzy search See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#search Only works for Find Person endpoint

func Skip

func Skip(n int) RequestOption

Skip will skip the first n rows from the results See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#skip Only works for Find endpoints

func Sort

func Sort(sortFields ...string) RequestOption

Sorts the result by a given field See more here https://developer.bcc.no/bcc-core-api/crud/query-parameters.html#sort Only works for Find endpoints

type Scope

type Scope string
const (
	ScopePersonsRead               Scope = "persons#read"
	ScopePersonsNameRead           Scope = "persons.name#read"
	ScopePersonsBirthDateRead      Scope = "persons.birth_date#read"
	ScopePersonsDeceasedDateRead   Scope = "persons.deceased_date#read"
	ScopePersonsNationalIdsRead    Scope = "persons.national_ids#read"
	ScopePersonsGenderRead         Scope = "persons.gender#read"
	ScopePersonsEmailRead          Scope = "persons.email#read"
	ScopePersonsPhoneRead          Scope = "persons.phone#read"
	ScopePersonsPreferencesRead    Scope = "persons.preferences#read"
	ScopePersonsAddressRead        Scope = "persons.address#read"
	ScopePersonsProfilePictureRead Scope = "persons.profile_picture#read"
	ScopePersonAffiliationsRead    Scope = "persons.affiliations#read"
	ScopePersonRelationsRead       Scope = "persons.relations#read"
	ScopePersonConsentsRead        Scope = "persons.consents#read"
	ScopePersonRoleAssignmentsRead Scope = "persons.role_assignments#read"
	ScopePersonPersonIdRead        Scope = "persons.person_id#read"
	ScopeOrgsRead                  Scope = "orgs#read"
	ScopeCountriesRead             Scope = "countries#read"
	ScopeRolesRead                 Scope = "roles#read"
	ScopeGroupsRead                Scope = "groups#read"

	ScopePersonsWrite               Scope = "persons#write"
	ScopePersonAffiliationsWrite    Scope = "persons.affiliations#write"
	ScopePersonRelationsWrite       Scope = "persons.relations#write"
	ScopePersonConsentsWrite        Scope = "persons.consents#write"
	ScopePersonRoleAssignmentsWrite Scope = "persons.role_assignments#write"
	ScopeOrgsWrite                  Scope = "orgs#write"
	ScopeCountriesWrite             Scope = "countries#write"
	ScopeRolesWrite                 Scope = "roles#write"
	ScopeGroupsWrite                Scope = "groups#write"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL