Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Campaigns for Apps endpoints #1

Merged
merged 3 commits into from
Jan 5, 2018
Merged

Conversation

tzengerink
Copy link
Contributor

@tzengerink tzengerink commented Jan 3, 2018

Reviewers: @spirosikmd @tzengerink @Rifinio @kioli @SuzettePaeta @gPinato

This PR does a couple of things, that I neatly arranged in their own commits.

Rename repo and package:

It renames the repository to 'api-go' to match our other clients and it renames the package to 'usabilla'.

Campaigns for Apps

It adds support for the new Campaigns for Apps endpoints. While at it I notice there is a lot of duplicate code and it would be nice to refactor that into DRYer and more maintainable code, which also allows for better testing of new endpoints. For now, however, the main goal is to support the new endpoints. I would like to consider refactoring the client as technical debt.

CI

It moves the continuous integration to CircleCI, like our other projects.

Teun Zengerink added 3 commits January 3, 2018 10:59
The package name was no longer considered mature. Also to align with the
clients for other languages, the name of the package was changed. Next
to that the location of the repo has also changed.

While at it, the copyright year has been adjusted to 2018 were
applicable.
After new endpoints have been made available to retrieve App Campaigns
and their results, the client is adjusted to support these new
endpoints.
Copy link
Member

@gPinato gPinato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10/10 would review again


err := json.Unmarshal(data, &response)
if err != nil {
return response, err
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is by convention that we always return the response even though an error occurred?
(I ask since when an error is not present we return it with nil, but I guess it does not matter much since we check if the error is present and otherwise we process the answer)

Copy link
Contributor Author

@tzengerink tzengerink Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's sort of a convention yes. That way on the other side you can do a

if err != nil {
    ...
}

or look at the http module on how this is sort of a convention.

)

var (
appFeedbackURI = appsURI + "/%s/feedback"
appFeedbackURI = appsURI + "/%s/feedback"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why there are so much space between appFeedbackURI and the '='

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the formatting Go uses, see documentation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ho ok thanks for the link

// appCampaignResults feeds the results channel with items. While HasMore is true it makes new API requests
// and sends them through the channel. Once it is false it closes the channel.
func appCampaignResults(acrc chan AppCampaignResultStruct, resp *AppCampaignResultsResponse, acr *AppCampaignResults, campaignID string) {
for {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels like it is an infinite for. Is it correct practice ? Could you use a while or something safer to break this look ? (And I have no idea if it's possible too)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go only knows about a for loop, it contains all loop functionality in a single keyword. See documentation

Copy link

@kagnamazian kagnamazian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good cleaning Job !!


acrc := make(chan AppCampaignResultStruct)

go appCampaignResults(acrc, resp, ac, campaignID)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acrc this is not really readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but it's sort of a Go convention to not use long variable names, see common codereview comments.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG so silly

func (acr *AppCampaignResults) Get(campaignID string, params map[string]string) (*AppCampaignResultsResponse, error) {
uri := fmt.Sprintf(appCampaignResultsURI, campaignID)

request := &request{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pure noob question, should we add a space before the {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My editor runs gofmt on the code when saving, so this is how it should be, read about gofmt to see what it does.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arf. ok, this is terrible language

@tzengerink tzengerink merged commit 9dca7dd into master Jan 5, 2018
@tzengerink tzengerink deleted the add-campaigns-for-apps branch January 5, 2018 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants