Skip to content

Latest commit

 

History

History
executable file
·
399 lines (289 loc) · 16.1 KB

README.md

File metadata and controls

executable file
·
399 lines (289 loc) · 16.1 KB

Evs

Overview

Operations about electric vehicles

Available Operations

GetBatteryCapacity

Description

Returns the total capacity of an electric vehicle's battery.

Permission

read_battery

Response body

Name Type Boolean
capacity number The total capacity of the vehicle's battery (in kilowatt-hours).

Example Usage

package main

import(
	"context"
	"log"
	gosdkv2 "github.com/smartcar/go-sdk-v2"
	"github.com/smartcar/go-sdk-v2/pkg/models/shared"
	"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)

func main() {
    s := gosdkv2.New(
        gosdkv2.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Evs.GetBatteryCapacity(ctx, operations.GetBatteryCapacityRequest{
        VehicleID: "unde",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.BatteryCapacity != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetBatteryCapacityRequest ✔️ The request object to use for the request.

Response

*operations.GetBatteryCapacityResponse, error

GetBatteryLevel

Description

Retrieve EV battery level of a vehicle.

Permission

read_battery

Response body

Name Type Boolean
percentRemaining number An EV battery’s state of charge (in percent).
range number The estimated remaining distance the vehicle can travel (in kilometers by default or in miles using the sc-unit-system.

Example Usage

package main

import(
	"context"
	"log"
	gosdkv2 "github.com/smartcar/go-sdk-v2"
	"github.com/smartcar/go-sdk-v2/pkg/models/shared"
	"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)

func main() {
    s := gosdkv2.New(
        gosdkv2.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Evs.GetBatteryLevel(ctx, operations.GetBatteryLevelRequest{
        VehicleID: "nulla",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.BatteryLevel != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetBatteryLevelRequest ✔️ The request object to use for the request.

Response

*operations.GetBatteryLevelResponse, error

GetChargingLimit

Description

Returns the current charge limit of an electric vehicle.

Example Usage

package main

import(
	"context"
	"log"
	gosdkv2 "github.com/smartcar/go-sdk-v2"
	"github.com/smartcar/go-sdk-v2/pkg/models/shared"
	"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)

func main() {
    s := gosdkv2.New(
        gosdkv2.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Evs.GetChargingLimit(ctx, operations.GetChargingLimitRequest{
        VehicleID: "corrupti",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.ChargeLimit != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetChargingLimitRequest ✔️ The request object to use for the request.

Response

*operations.GetChargingLimitResponse, error

GetChargingStatus

Description

Returns the current charge status of an electric vehicle.

Permission

read_charge

Response body

Name Type Boolean
isPluggedIn boolean Indicates whether a charging cable is currently plugged into the vehicle’s charge port.
state string Indicates whether the vehicle is currently charging. Options: CHARGING FULLY_CHARGED NOT_CHARGING

Example Usage

package main

import(
	"context"
	"log"
	gosdkv2 "github.com/smartcar/go-sdk-v2"
	"github.com/smartcar/go-sdk-v2/pkg/models/shared"
	"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)

func main() {
    s := gosdkv2.New(
        gosdkv2.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Evs.GetChargingStatus(ctx, operations.GetChargingStatusRequest{
        VehicleID: "illum",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.ChargeStatus != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.GetChargingStatusRequest ✔️ The request object to use for the request.

Response

*operations.GetChargingStatusResponse, error

SetChargingLimit

Description

Returns the current charge limit of an electric vehicle.

Example Usage

package main

import(
	"context"
	"log"
	gosdkv2 "github.com/smartcar/go-sdk-v2"
	"github.com/smartcar/go-sdk-v2/pkg/models/shared"
	"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)

func main() {
    s := gosdkv2.New(
        gosdkv2.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Evs.SetChargingLimit(ctx, operations.SetChargingLimitRequest{
        ChargeLimit: &shared.ChargeLimit{
            Limit: gosdkv2.Float32(1),
        },
        VehicleID: "vel",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.SuccessResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.SetChargingLimitRequest ✔️ The request object to use for the request.

Response

*operations.SetChargingLimitResponse, error

StartStopCharge

Description

Returns the current charge status of an electric vehicle.

Permission

read_charge

Response body

Name Type Boolean
isPluggedIn boolean Indicates whether a charging cable is currently plugged into the vehicle’s charge port.
state string Indicates whether the vehicle is currently charging. Options: CHARGING FULLY_CHARGED NOT_CHARGING

Example Usage

package main

import(
	"context"
	"log"
	gosdkv2 "github.com/smartcar/go-sdk-v2"
	"github.com/smartcar/go-sdk-v2/pkg/models/shared"
	"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)

func main() {
    s := gosdkv2.New(
        gosdkv2.WithSecurity(shared.Security{
            BasicAuth: &shared.SchemeBasicAuth{
                Password: "",
                Username: "",
            },
        }),
    )

    ctx := context.Background()
    res, err := s.Evs.StartStopCharge(ctx, operations.StartStopChargeRequest{
        ChargeAction: &shared.ChargeAction{
            Action: shared.ChargeActionActionStart.ToPointer(),
        },
        VehicleID: "error",
    })
    if err != nil {
        log.Fatal(err)
    }

    if res.SuccessResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.StartStopChargeRequest ✔️ The request object to use for the request.

Response

*operations.StartStopChargeResponse, error