Skip to content

feat: Implement option to apply discount codes #1960

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

Merged
merged 1 commit into from
Jun 20, 2019

Conversation

liveHarshit
Copy link
Member

@liveHarshit liveHarshit commented Jun 15, 2019

Fixes #1778

@liveHarshit liveHarshit changed the title [WIP ]feat: Discount codes [WIP] feat: Discount codes Jun 15, 2019
@liveHarshit
Copy link
Member Author

I'm getting following exception for all discount APIs -

E/TicketsViewModel$fetchDiscountCodes: Error fetching discount codes 150
    retrofit2.adapter.rxjava2.HttpException: HTTP 401 UNAUTHORIZED

@iamareebjamal
Copy link
Member

You are not an admin, why should you be able to see all discount codes?

@liveHarshit
Copy link
Member Author

You are not an admin, why should you be able to see all discount codes?

Got it, so I need to post the discount code then handle the response from the server. ?

val event: Event
val event: Event? = null,
@Relationship("tickets")
val tickets: List<Ticket>? = null
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm getting following response -

DiscountCode(id=7, code=FOSSASIA, validFrom=2019-06-10T05:48:37.962000+00:00, minQuantity=1, createdAt=2019-06-10T05:49:06.179000+00:00, ticketsNumber=5, value=10.0, maxQuantity=1, isActive=true, usedFor=ticket, validTill=2019-08-16T18:30:00+00:00, discountUrl=https://fossasia.github.io/open-event-frontend/e/7376e026?code=FOSSASIA, type=amount, event=null, tickets=null)

How can I store that relationship object to relate it with event and tickets -

"relationships": {
      "events": {
        "links": {
          "self": "/v1/discount-codes/4/relationships/events",
          "related": "/v1/discount-codes/4/events"
        }
      },
      "tickets": {
        "links": {
          "self": "/v1/discount-codes/1/relationships/tickets",
          "related": "/v1/discount-codes/1/tickets"
        }
      }
    }

For this DiscountCode class, they are getting null.

Copy link
Member

Choose a reason for hiding this comment

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

They are null. You haven't included them in the query. Secondly, instead of getting tickets of discount code, you should get discount code of ticket

Copy link
Member Author

Choose a reason for hiding this comment

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

you should get discount code of ticket

I thought it will also give HTTP 401 UNAUTHORIZED. Working 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

HTTP 401 UNAUTHORIZED

Same for end point: /v1/tickets/{ticket_id}/discount-codes{?sort,filter}

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I remebered. Obviously you can't see the discount codes. Or what would be the point. Imagine DigitalOcean API showing that BLACKOUT100 will give you 100% off

Why you need to fetch the discount codes?

Copy link
Member Author

@liveHarshit liveHarshit Jun 19, 2019

Choose a reason for hiding this comment

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

Okay, got it. You want to say that endpoint /v1/discount-codes/{code} should also give HTTP 401 UNAUTHORIZED?

Copy link
Member Author

Choose a reason for hiding this comment

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

Which I'm using currently

Copy link
Member

Choose a reason for hiding this comment

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

OK, if you have got a discount code, it doesn't throw the error? If so, then it is fine 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, if you have got a discount code, it doesn't throw the error? If so, then it is fine

Yes, that's I'm using. Fetching details after submitting the discount code.

Copy link
Member Author

Choose a reason for hiding this comment

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

If so, then it is fine

@iamareebjamal Please review!

@liveHarshit liveHarshit force-pushed the 1778 branch 3 times, most recently from 47e8433 to f1c15c0 Compare June 17, 2019 15:27
@liveHarshit liveHarshit changed the title [WIP] feat: Discount codes feat: Implement option to apply discount codes Jun 17, 2019
@auto-label auto-label bot added the feature label Jun 17, 2019
@liveHarshit liveHarshit requested a review from anhanh11001 June 17, 2019 15:31
anhanh11001
anhanh11001 previously approved these changes Jun 17, 2019
Copy link
Contributor

@anhanh11001 anhanh11001 left a comment

Choose a reason for hiding this comment

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

Rest is good

@fossasia fossasia deleted a comment Jun 17, 2019
@fossasia fossasia deleted a comment Jun 17, 2019
@fossasia fossasia deleted a comment Jun 17, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 18, 2019
@fossasia fossasia deleted a comment Jun 19, 2019
@iamareebjamal
Copy link
Member

PRF

@liveHarshit
Copy link
Member Author

Rest is good

@anhanh11001 Please review.

@fossasia fossasia deleted a comment Jun 20, 2019
@fossasia fossasia deleted a comment Jun 20, 2019
@fossasia fossasia deleted a comment Jun 20, 2019
@fossasia fossasia deleted a comment Jun 20, 2019
@liveHarshit liveHarshit requested a review from anhanh11001 June 20, 2019 09:31
Copy link
Contributor

@anhanh11001 anhanh11001 left a comment

Choose a reason for hiding this comment

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

I think rest is good

if (currentDiscountCode != null)
holder.bind(ticket, selectedListener, eventCurrency, qty, currentDiscountCode)
else
holder.bind(ticket, selectedListener, eventCurrency, qty)
Copy link
Contributor

Choose a reason for hiding this comment

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

currentDiscountCode != null is unnecessary I think:
just add holder.bind(ticket, selectedListener, eventCurrency, qty, currentDiscountCode)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes right, that's why I have take null as a default value, forgot to change it. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@iamareebjamal iamareebjamal merged commit 3c9f518 into fossasia:development Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to apply discount code
3 participants