-
Notifications
You must be signed in to change notification settings - Fork 553
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
Conversation
I'm getting following exception for all discount APIs -
|
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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}
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
47e8433
to
f1c15c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest is good
app/src/main/java/org/fossasia/openevent/general/ticket/TicketViewHolder.kt
Outdated
Show resolved
Hide resolved
PRF |
@anhanh11001 Please review. |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Fixes #1778