-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
example_store_card.rb
130 lines (112 loc) · 2.38 KB
/
example_store_card.rb
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
module Passkit
class ExampleStoreCard < BasePass
def pass_type
:storeCard
# :coupon
end
def foreground_color
"rgb(0, 0, 0)"
end
def background_color
"rgb(255, 255, 255)"
end
def organization_name
"Passkit"
end
def description
"A basic description for a pass"
end
# A pass can have up to ten relevant locations
#
# @see https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/PassKit_PG/Creating.html
def locations
[]
end
def voided
false
end
def file_name
@file_name ||= SecureRandom.uuid
end
# QRCode by default
def barcodes
[
{ messageEncoding: "iso-8859-1",
format: "PKBarcodeFormatQR",
message: "https://github.com/coorasse/passkit",
altText: "https://github.com/coorasse/passkit" }
]
end
# Barcode example
# def barcode
# { messageEncoding: 'iso-8859-1',
# format: 'PKBarcodeFormatCode128',
# message: '12345',
# altText: '12345' }
# end
def logo_text
"Loyalty Card"
end
def relevant_date
Time.current.strftime('%Y-%m-%dT%H:%M:%S%:z')
end
def expiration_date
# Expire the pass tomorrow
(Time.current + 1.day).strftime('%Y-%m-%dT%H:%M:%S%:z')
end
def semantics
{
balance: {
amount: "100",
currencyCode: "USD"
}
}
end
def header_fields
[{
key: "balance",
label: "Balance",
value: 100,
currencyCode: "$"
}]
end
def back_fields
[{
key: "example1",
label: "Code",
value: "0123456789"
},
{
key: "example2",
label: "Creator",
value: "https://github.com/coorasse"
},
{
key: "example3",
label: "Contact",
value: "rodi@hey.com"
}]
end
def auxiliary_fields
[{
key: "name",
label: "Name",
value: "Alessandro Rodi"
},
{
key: "email",
label: "Email",
value: "rodi@hey.com"
},
{
key: "phone",
label: "Phone",
value: "+41 1234567890"
}]
end
private
def folder_name
self.class.name.demodulize.underscore
end
end
end