1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
use super::*;
/// The PaymentRequestEvent class.
/// [`PaymentRequestEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct PaymentRequestEvent {
inner: ExtendableEvent,
}
impl FromVal for PaymentRequestEvent {
fn from_val(v: &Any) -> Self {
PaymentRequestEvent {
inner: ExtendableEvent::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for PaymentRequestEvent {
type Target = ExtendableEvent;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for PaymentRequestEvent {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for PaymentRequestEvent {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for PaymentRequestEvent {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<PaymentRequestEvent> for Any {
fn from(s: PaymentRequestEvent) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&PaymentRequestEvent> for Any {
fn from(s: &PaymentRequestEvent) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(PaymentRequestEvent);
impl PaymentRequestEvent {
/// Getter of the `topOrigin` attribute.
/// [`PaymentRequestEvent.topOrigin`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/topOrigin)
pub fn top_origin(&self) -> JsString {
self.inner.get("topOrigin").as_::<JsString>()
}
}
impl PaymentRequestEvent {
/// Getter of the `paymentRequestOrigin` attribute.
/// [`PaymentRequestEvent.paymentRequestOrigin`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/paymentRequestOrigin)
pub fn payment_request_origin(&self) -> JsString {
self.inner.get("paymentRequestOrigin").as_::<JsString>()
}
}
impl PaymentRequestEvent {
/// Getter of the `paymentRequestId` attribute.
/// [`PaymentRequestEvent.paymentRequestId`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/paymentRequestId)
pub fn payment_request_id(&self) -> JsString {
self.inner.get("paymentRequestId").as_::<JsString>()
}
}
impl PaymentRequestEvent {
/// Getter of the `methodData` attribute.
/// [`PaymentRequestEvent.methodData`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/methodData)
pub fn method_data(&self) -> TypedArray<PaymentMethodData> {
self.inner
.get("methodData")
.as_::<TypedArray<PaymentMethodData>>()
}
}
impl PaymentRequestEvent {
/// Getter of the `total` attribute.
/// [`PaymentRequestEvent.total`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/total)
pub fn total(&self) -> Object {
self.inner.get("total").as_::<Object>()
}
}
impl PaymentRequestEvent {
/// Getter of the `modifiers` attribute.
/// [`PaymentRequestEvent.modifiers`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/modifiers)
pub fn modifiers(&self) -> TypedArray<PaymentDetailsModifier> {
self.inner
.get("modifiers")
.as_::<TypedArray<PaymentDetailsModifier>>()
}
}
impl PaymentRequestEvent {
/// Getter of the `paymentOptions` attribute.
/// [`PaymentRequestEvent.paymentOptions`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/paymentOptions)
pub fn payment_options(&self) -> Object {
self.inner.get("paymentOptions").as_::<Object>()
}
}
impl PaymentRequestEvent {
/// Getter of the `shippingOptions` attribute.
/// [`PaymentRequestEvent.shippingOptions`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/shippingOptions)
pub fn shipping_options(&self) -> TypedArray<PaymentShippingOption> {
self.inner
.get("shippingOptions")
.as_::<TypedArray<PaymentShippingOption>>()
}
}
impl PaymentRequestEvent {
/// The `new PaymentRequestEvent(..)` constructor, creating a new PaymentRequestEvent instance
pub fn new(type_: &JsString) -> PaymentRequestEvent {
Self {
inner: Any::global("PaymentRequestEvent")
.new(&[type_.into()])
.as_::<ExtendableEvent>(),
}
}
}
impl PaymentRequestEvent {
/// The `new PaymentRequestEvent(..)` constructor, creating a new PaymentRequestEvent instance
pub fn new_with_event_init_dict(
type_: &JsString,
event_init_dict: &PaymentRequestEventInit,
) -> PaymentRequestEvent {
Self {
inner: Any::global("PaymentRequestEvent")
.new(&[type_.into(), event_init_dict.into()])
.as_::<ExtendableEvent>(),
}
}
}
impl PaymentRequestEvent {
/// The openWindow method.
/// [`PaymentRequestEvent.openWindow`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/openWindow)
pub fn open_window(&self, url: &JsString) -> Promise<WindowClient> {
self.inner
.call("openWindow", &[url.into()])
.as_::<Promise<WindowClient>>()
}
}
impl PaymentRequestEvent {
/// The changePaymentMethod method.
/// [`PaymentRequestEvent.changePaymentMethod`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/changePaymentMethod)
pub fn change_payment_method(
&self,
method_name: &JsString,
) -> Promise<PaymentRequestDetailsUpdate> {
self.inner
.call("changePaymentMethod", &[method_name.into()])
.as_::<Promise<PaymentRequestDetailsUpdate>>()
}
}
impl PaymentRequestEvent {
/// The changePaymentMethod method.
/// [`PaymentRequestEvent.changePaymentMethod`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/changePaymentMethod)
pub fn change_payment_method_with_method_details(
&self,
method_name: &JsString,
method_details: &Object,
) -> Promise<PaymentRequestDetailsUpdate> {
self.inner
.call(
"changePaymentMethod",
&[method_name.into(), method_details.into()],
)
.as_::<Promise<PaymentRequestDetailsUpdate>>()
}
}
impl PaymentRequestEvent {
/// The changeShippingAddress method.
/// [`PaymentRequestEvent.changeShippingAddress`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/changeShippingAddress)
pub fn change_shipping_address(&self) -> Promise<PaymentRequestDetailsUpdate> {
self.inner
.call("changeShippingAddress", &[])
.as_::<Promise<PaymentRequestDetailsUpdate>>()
}
}
impl PaymentRequestEvent {
/// The changeShippingAddress method.
/// [`PaymentRequestEvent.changeShippingAddress`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/changeShippingAddress)
pub fn change_shipping_address_with_shipping_address(
&self,
shipping_address: &AddressInit,
) -> Promise<PaymentRequestDetailsUpdate> {
self.inner
.call("changeShippingAddress", &[shipping_address.into()])
.as_::<Promise<PaymentRequestDetailsUpdate>>()
}
}
impl PaymentRequestEvent {
/// The changeShippingOption method.
/// [`PaymentRequestEvent.changeShippingOption`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/changeShippingOption)
pub fn change_shipping_option(
&self,
shipping_option: &JsString,
) -> Promise<PaymentRequestDetailsUpdate> {
self.inner
.call("changeShippingOption", &[shipping_option.into()])
.as_::<Promise<PaymentRequestDetailsUpdate>>()
}
}
impl PaymentRequestEvent {
/// The respondWith method.
/// [`PaymentRequestEvent.respondWith`](https://developer.mozilla.org/en-US/docs/Web/API/PaymentRequestEvent/respondWith)
pub fn respond_with(
&self,
handler_response_promise: &Promise<PaymentHandlerResponse>,
) -> Undefined {
self.inner
.call("respondWith", &[handler_response_promise.into()])
.as_::<Undefined>()
}
}