Skip to content

Commit

Permalink
Release v0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 31, 2023
1 parent f6ac073 commit b584e8b
Show file tree
Hide file tree
Showing 55 changed files with 11,582 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci

on: [push]

jobs:
compile:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up go
uses: actions/setup-go@v4

- name: Compile
run: go build ./...
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up go
uses: actions/setup-go@v4

- name: Test
run: go test ./...
20 changes: 20 additions & 0 deletions athome_phlebotomy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This file was auto-generated by Fern from our API Definition.

package api

import (
core "github.com/fern-vital/vital-go/core"
)

type AppointmentBookingRequest struct {
BookingKey string `json:"booking_key"`
}

type AppointmentCancelRequest struct {
CancellationReasonId string `json:"cancellation_reason_id"`
Notes *core.Optional[string] `json:"notes,omitempty"`
}

type AppointmentRescheduleRequest struct {
BookingKey string `json:"booking_key"`
}
289 changes: 289 additions & 0 deletions athomephlebotomy/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
// This file was auto-generated by Fern from our API Definition.

package athomephlebotomy

import (
bytes "bytes"
context "context"
json "encoding/json"
errors "errors"
fmt "fmt"
vitalgo "github.com/fern-vital/vital-go"
core "github.com/fern-vital/vital-go/core"
io "io"
http "net/http"
)

type Client struct {
baseURL string
httpClient core.HTTPClient
header http.Header
}

func NewClient(opts ...core.ClientOption) *Client {
options := core.NewClientOptions()
for _, opt := range opts {
opt(options)
}
return &Client{
baseURL: options.BaseURL,
httpClient: options.HTTPClient,
header: options.ToHeader(),
}
}

// Return the available time slots to book an appointment with a phlebotomist
// for the given address and order.
//
// Your Order ID.
func (c *Client) AppointmentAvailability(ctx context.Context, orderId string, request *vitalgo.UsAddress) (*vitalgo.AppointmentAvailabilitySlots, error) {
baseURL := ""
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"v3/order/%v/phlebotomy/appointment/availability", orderId)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 422:
value := new(vitalgo.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *vitalgo.AppointmentAvailabilitySlots
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodPost,
request,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}

// Book an at-home phlebotomy appointment.
//
// Your Order ID.
func (c *Client) BookAppointment(ctx context.Context, orderId string, request *vitalgo.AppointmentBookingRequest) (*vitalgo.ClientFacingAppointment, error) {
baseURL := ""
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"v3/order/%v/phlebotomy/appointment/book", orderId)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 422:
value := new(vitalgo.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *vitalgo.ClientFacingAppointment
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodPost,
request,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}

// Reschedule a previously booked at-home phlebotomy appointment.
//
// Your Order ID.
func (c *Client) RescheduleAppointment(ctx context.Context, orderId string, request *vitalgo.AppointmentRescheduleRequest) (*vitalgo.ClientFacingAppointment, error) {
baseURL := ""
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"v3/order/%v/phlebotomy/appointment/reschedule", orderId)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 422:
value := new(vitalgo.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *vitalgo.ClientFacingAppointment
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodPatch,
request,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}

// Cancel a previously booked at-home phlebotomy appointment.
//
// Your Order ID.
func (c *Client) CancelAppointment(ctx context.Context, orderId string, request *vitalgo.AppointmentCancelRequest) (*vitalgo.ClientFacingAppointment, error) {
baseURL := ""
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"v3/order/%v/phlebotomy/appointment/cancel", orderId)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 422:
value := new(vitalgo.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *vitalgo.ClientFacingAppointment
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodPatch,
request,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}

// Get the list of reasons for cancelling an at-home phlebotomy appointment.
func (c *Client) CancellationReason(ctx context.Context) ([]*vitalgo.ClientFacingAppointmentCancellationReason, error) {
baseURL := ""
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "v3/order/phlebotomy/appointment/cancellation-reasons"

var response []*vitalgo.ClientFacingAppointmentCancellationReason
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodGet,
nil,
&response,
false,
c.header,
nil,
); err != nil {
return response, err
}
return response, nil
}

// Get the appointment associated with an order.
//
// Your Order ID.
func (c *Client) GetAppointment(ctx context.Context, orderId string) (*vitalgo.ClientFacingAppointment, error) {
baseURL := ""
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"v3/order/%v/phlebotomy/appointment", orderId)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 422:
value := new(vitalgo.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *vitalgo.ClientFacingAppointment
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodGet,
nil,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}
21 changes: 21 additions & 0 deletions body.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// This file was auto-generated by Fern from our API Definition.

package api

type BodyGetRequest struct {
// Provider oura/strava etc
Provider *string `json:"-"`
// Date from in YYYY-MM-DD or ISO formatted date time. If a date is provided without a time, the time will be set to 00:00:00
StartDate string `json:"-"`
// Date to YYYY-MM-DD or ISO formatted date time. If a date is provided without a time, the time will be set to 23:59:59
EndDate *string `json:"-"`
}

type BodyGetRawRequest struct {
// Provider oura/strava etc
Provider *string `json:"-"`
// Date from in YYYY-MM-DD or ISO formatted date time. If a date is provided without a time, the time will be set to 00:00:00
StartDate string `json:"-"`
// Date to YYYY-MM-DD or ISO formatted date time. If a date is provided without a time, the time will be set to 23:59:59
EndDate *string `json:"-"`
}
Loading

0 comments on commit b584e8b

Please sign in to comment.