bmm

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 10 Imported by: 2

README

Golang SDK for BMM

Status

This SDK implements only the things needed by BCC Media at the moment. It is primarily meant for use in the backend.

PRs expanding it are welcome.

Usage

import (
    "github.com/bcc-code/bmm-sdk-golang"
)

func main() {
    token, err:= bmm.Token(...)
    if err != nil {
        panic(err)
    }
    
    client := bmm.NewApiClient("http://bmm.base.url", token)
}

Logging

Internally the SDK uses the slog package for logging. A custom logger can be set using the SetLogger(logger *slog.Logger) method.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

func NewApiClient

func NewApiClient(baseURL string, token *Token) *APIClient

NewApiClient creates a new BMM API client, using the provided token

It sets the language to norwegian. There is currently no way to change this. PRs welcome :).

func (*APIClient) GetAlbumTracks

func (c *APIClient) GetAlbumTracks(albumId string) ([]Item, error)

func (*APIClient) GetAlbums

func (c *APIClient) GetAlbums(year int) ([]Item, error)

func (*APIClient) GetHVHEGlobalStats added in v0.1.2

func (c *APIClient) GetHVHEGlobalStats() (*GlobalStats, error)

func (*APIClient) GetLanguages

func (c *APIClient) GetLanguages() ([]Overview, error)

func (*APIClient) GetPodcastTracks

func (c *APIClient) GetPodcastTracks(podcastTag string, limit int) ([]Item, error)

func (*APIClient) GetYears

func (c *APIClient) GetYears() ([]Year, error)

func (*APIClient) HVHEGameNight added in v0.1.2

func (c *APIClient) HVHEGameNight(churchUID uuid.UUID, winner string, gameNightNumber int, units int) error

func (*APIClient) HVHEGameNight3 added in v0.1.8

func (c *APIClient) HVHEGameNight3(winner string, units int) error

func (*APIClient) HVHENotifications added in v0.1.2

func (c *APIClient) HVHENotifications(churchUID uuid.UUID, winner string, gameNightNumber int) error

func (*APIClient) SetBaseURL

func (c *APIClient) SetBaseURL(baseURL string) *APIClient

func (*APIClient) SetDebug added in v0.1.2

func (c *APIClient) SetDebug(debug bool) *APIClient

func (*APIClient) SetLogger added in v0.1.1

func (c *APIClient) SetLogger(logger *slog.Logger) *APIClient

func (*APIClient) SubmitAnswer added in v0.1.6

func (c *APIClient) SubmitAnswer(QuestionID string, AnsweredCorrectly bool, SelectedAnswerID string, PersonID string) error

type GlobalStats added in v0.1.2

type GlobalStats struct {
	Boys  int `json:"boys"`
	Girls int `json:"girls"`
}

type HVHEGameNight3Request added in v0.1.8

type HVHEGameNight3Request struct {
	Winner string `json:"winner"`
	Units  int    `json:"units"`
}

type HVHEGameNightRequest added in v0.1.2

type HVHEGameNightRequest struct {
	ChurchUID       string `json:"church_uid"`
	Winner          string `json:"winner"`
	GameNightNumber int    `json:"game_night_number"`
	Units           int    `json:"units"`
}

type HVHENotificationsRequest added in v0.1.2

type HVHENotificationsRequest struct {
	ChurchUID       string `json:"church_uid"`
	Winner          string `json:"winner"`
	GameNightNumber int    `json:"game_night_number"`
}

type ID

type ID int64

func MustParse

func MustParse(s string) ID

func Parse

func Parse(s string) (ID, error)

func (ID) String

func (id ID) String() string

type Item

type Item struct {
	Meta      Meta        `json:"_meta"`
	BmmID     interface{} `json:"bmm_id"`
	Cover     string      `json:"cover"`
	ID        int         `json:"id"`
	Languages []string    `json:"languages"`
	//ParentID    interface{} `json:"parent_id"`
	PublishedAt            time.Time `json:"published_at"`
	Tags                   []string  `json:"tags"`
	Language               string    `json:"language"`
	Title                  string    `json:"title"`
	Type                   string    `json:"type"`
	Tracks                 []Item    `json:"children"`
	TranscriptionLanguages []string  `json:"transcription_languages"`
	HasTranscription       bool      `json:"has_transcription"`
}

type Meta

type Meta struct {
	ContainedTypes []string  `json:"contained_types"`
	IsVisible      bool      `json:"is_visible"`
	ModifiedAt     time.Time `json:"modified_at"`
	ModifiedBy     string    `json:"modified_by"`
}

type Overview

type Overview struct {
	Name      string   `json:"name"`
	Languages []string `json:"languages"`
}

type QuestionAnswerRequest added in v0.1.4

type QuestionAnswerRequest struct {
	QuestionID        string `json:"question_id"`
	AnsweredCorrectly bool   `json:"answered_correctly"`
	SelectedAnswerID  string `json:"selected_answer_id"`
	PersonID          int    `json:"person_id"`
}

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	Scope       string `json:"scope"`
	ExpiresIn   int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
	CreatedAt   time.Time
	// contains filtered or unexported fields
}

func NewToken

func NewToken(tokenBaseURL, clientID, clientSecret, audience string) (*Token, error)

NewToken creates a new token for M2M communication with BMM API

func (*Token) GetAccessToken

func (t *Token) GetAccessToken() (string, error)

GetAccessToken returns the access token, if it is expired, it will be refreshed automatically

type Year

type Year struct {
	Year  uint32 `json:"year"`
	Count uint32 `json:"count"`
}

Jump to

Keyboard shortcuts

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