Giter Club home page Giter Club logo

mailerlite-go's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mailerlite-go's Issues

Subscriber creation function is broken

The implementation of the subscriber creation function doesn't comply with the REST API docs.

In the linked doc, only the email is required and the groups is an array of group ids. However, this call:

subscriber := &mailerlite.Subscriber{
	Email:  "[email protected]",
	Groups: []mailerlite.Group{{ID: "12345"}},
}

client.Subscriber.Create(ctx, subscriber)

Fails with:

POST https://connect.mailerlite.com/api/subscribers: 422 Must be a valid object (and 1 more error) map[fields:[Must be a valid object] groups.0:[The groups.0 must be a number.]]

This is because the whole Subscriber struct is being marshalled and sent along with the request.

For now, I have resorted to calling the endpoint directly.

[SDK] Create missing endpoints - Go

Automations:

  • List all automations
  • Get an automation
  • Get the subscriber activity for an automation

Batching:

  • Make multiple requests in a single call

Timezones:

  • Get all available timezones

Campaign languages:

  • Get a list of all campaign languages available

Unable to unit test package usage

I'd like to be able to unit test my code that I use for Mailerlite access. Ideally I would just take an interface from the package and supply a custom type that satisfies the interface and returns the responses I need for testing. However the issue is that there doesn't exist such an interface and I can't create one myself because there are unexported types returned. Specifically I can mention SubscriberService where operations often return a *rootSubscriber which I can neither add to my own interface nor would be able to return as part of a custom struct.

Please consider a way to help unit test external usages of this package

Error when trying to add new Subscriber

Hello, I am trying to add a new subscriber using go and gin-gonic, but I keep getting an error

"error": "POST https://connect.mailerlite.com/api/subscribers: 422 The groups field must be an array. map[groups:[The groups field must be an array.]]",

Here is my code

var MAILERLITE_API = os.Getenv("MAILERLITE_API")
func SaveNewsletter() gin.HandlerFunc {
	return func(c *gin.Context) {
		client := mailerlite.NewClient(MAILERLITE_API)
		ctx := context.TODO()
		subscriber := &mailerlite.Subscriber{
			Email: "[email protected]",
			Fields: map[string]interface{}{
				"city": "Vilnius",
			},
		}
		newSubscriber, _, err := client.Subscriber.Create(ctx, subscriber)
		if err != nil {
			c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
			return
		}
		log.Println(err, newSubscriber)
		c.JSON(http.StatusOK, gin.H{
			"success":    true,
			"subscriber": newSubscriber.Data,
		})

	}
}

Error unmarshaling campaign list -- wrong type for 'settings' field

Calling the client.Campaign.List method results in the following error:

json: cannot unmarshal array into Go struct field Campaign.data.settings of type mailerlite.CampaignSettings

The API version that the client specifies (2022-12-01) causes the server to return an array for the 'settings' field of a campaign, while the client expects an object. (It looks like the server started returning an object instead of an array at version 2023-01-11).

Campaign scheduling function ignrores TimezoneID

I suspect this is an issue with the web service (not this Go client) but I am raising this here with the hope that it gets escalated to the right team.

Take a look at this function.

According to the API docs, the timezone_id "Must be a valid timezone id, defaults to the account's timezone id". This means it will use the timezone id if it's passed, otherwise, it will use the account's timezone.

On the dashboard, update your account time zone to any that is ahead of UTC; e.g. "Asia/Tokyo".

Now, if you call the campaign scheduling function as I did above, and pass 426 (UTC) to TimezoneID (assuming you execute the program on a machine with UTC time zone), the call with fail with:

POST https://connect.mailerlite.com/api/campaigns/${CAMPAIGN_ID}/schedule: 422 Please select time in the future map[schedule.hours:[Please select time in the future]].

However, if you change the timezone on the dashboard to UTC, the API succeeds.

[SDK] Create the Groups endpoint - Go

  • Get list of groups
  • Create a group
  • Get subscribers belonging to a group
  • Assign subscriber to a group
  • Unassign subscriber from a group
  • Update a group (name, etc.)
  • Delete a group

[SDK] Create the Stats endpoint - Go

  • Get a list of sent campaigns
  • Get stats for a sent campaign
  • Get a subscribers of sent campaign
  • Get a list of forms by type
  • Get a stats of a form by type
  • Get subscribers of a form by type
  • Get a list of automations
  • Get a stats for a specific automation
  • Get a list of subscribers of a specific automation by type (completed, failed, etc.)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/test.yaml
  • actions/checkout v4
  • actions/setup-go v5
gomod
go.mod
  • go 1.18
  • github.com/google/go-querystring v1.1.0
  • github.com/stretchr/testify v1.9.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.