Class: Fosbury::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fosbury/client.rb

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



9
10
11
# File 'lib/fosbury/client.rb', line 9

def initialize
  @endpoint = Fosbury.endpoint || "https://app.fosbury.co/api/v1/"
end

Instance Method Details

#archive_pass(pass_id) ⇒ Object



85
86
87
# File 'lib/fosbury/client.rb', line 85

def archive_pass pass_id
  post "#{@endpoint}passes/#{pass_id}/archive"
end

#create_campaign(template_id, options = {}) ⇒ Object



44
45
46
47
# File 'lib/fosbury/client.rb', line 44

def create_campaign template_id, options={}
  options[:template_id] = template_id
  post "#{@endpoint}campaigns", options
end

#create_campaign_backfield(campaign_id, title, description) ⇒ Object



120
121
122
123
124
# File 'lib/fosbury/client.rb', line 120

def create_campaign_backfield campaign_id, title, description
  raise "Please provide a campaign_id" if campaign_id.nil?
  options = { title: title, description: description }
  post "#{@endpoint}campaigns/#{campaign_id}/backfields", options
end

#create_campaign_beacon(campaign_id, proximity_uuid, relevant_text, major = nil, minor = nil) ⇒ Object



137
138
139
140
141
142
143
# File 'lib/fosbury/client.rb', line 137

def create_campaign_beacon campaign_id, proximity_uuid, relevant_text, major=nil, minor=nil
  raise "Please provide a campaign_id" if campaign_id.nil?
  options = { campaign_id: campaign_id, proximity_uuid: proximity_uuid, relevant_text: relevant_text}
  options[:major] = major if !major.nil?
  options[:minor] = minor if !minor.nil?
  post "#{@endpoint}campaigns/#{campaign_id}/ibeacons", options
end

#create_campaign_location(campaign_id, lat, long, name, relevant_text, address = '') ⇒ Object



103
104
105
106
107
# File 'lib/fosbury/client.rb', line 103

def create_campaign_location campaign_id, lat, long, name, relevant_text, address=''
  raise "Please provide a campaign_id" if campaign_id.nil?
  options = { campaign_id: campaign_id, lat: lat, long: long, name: name, relevant_text: relevant_text, address: address}
  post "#{@endpoint}campaigns/#{campaign_id}/locations", options
end

#create_pass(campaign_id, options = {}) ⇒ Object



49
50
51
52
53
# File 'lib/fosbury/client.rb', line 49

def create_pass campaign_id, options={}
  raise "Please provide a campaign_id" if campaign_id.nil?
  options[:campaign_id] = campaign_id
  post "#{@endpoint}passes", options
end

#create_program_backfield(program_id, title, description) ⇒ Object



231
232
233
234
235
# File 'lib/fosbury/client.rb', line 231

def create_program_backfield program_id, title, description
  raise "Please provide a program_id" if program_id.nil?
  options = { title: title, description: description }
  post "#{@endpoint}programs/#{program_id}/backfields", options
end

#create_program_beacon(program_id, proximity_uuid, relevant_text, major = nil, minor = nil) ⇒ Object



248
249
250
251
252
253
254
# File 'lib/fosbury/client.rb', line 248

def create_program_beacon program_id, proximity_uuid, relevant_text, major=nil, minor=nil
  raise "Please provide a program_id" if program_id.nil?
  options = { program_id: program_id, proximity_uuid: proximity_uuid, relevant_text: relevant_text}
  options[:major] = major if !major.nil?
  options[:minor] = minor if !minor.nil?
  post "#{@endpoint}programs/#{program_id}/ibeacons", options
end

#create_program_location(program_id, lat, long, name, address = '') ⇒ Object



214
215
216
217
218
# File 'lib/fosbury/client.rb', line 214

def create_program_location program_id, lat, long, name, address=''
  raise "Please provide a program_id" if program_id.nil?
  options = { program_id: program_id, lat: lat, long: long, name: name, address: address }
  post "#{@endpoint}programs/#{program_id}/locations", options
end

#create_program_member(program_id, customer_number, first_name, last_name) ⇒ Object



180
181
182
183
184
185
186
187
188
189
# File 'lib/fosbury/client.rb', line 180

def create_program_member program_id, customer_number, first_name, last_name
  raise "Please provide a program_id" if program_id.nil?
  raise "Please provide a customer_number" if customer_number.nil?
  raise "Please provide a first_name" if first_name.nil?
  raise "Please provide a last_name" if last_name.nil?

  options = { customer_number: customer_number, first_name: first_name, last_name: last_name}

  post "#{@endpoint}programs/#{program_id}/members", options
end

#create_template(name, style, options = {}) ⇒ Object



37
38
39
40
41
42
# File 'lib/fosbury/client.rb', line 37

def create_template name, style, options={}
  options[:name] = name
  options[:style] = style

  post "#{@endpoint}templates", options
end

#delete_campaign(campaign_id) ⇒ Object



73
74
75
# File 'lib/fosbury/client.rb', line 73

def delete_campaign campaign_id
  delete "#{@endpoint}campaigns/#{campaign_id}"
end

#delete_campaign_backfield(campaign_id, backfield_id) ⇒ Object



126
127
128
129
130
# File 'lib/fosbury/client.rb', line 126

def delete_campaign_backfield campaign_id, backfield_id
  raise "Please provide a campaign_id" if campaign_id.nil?
  raise "Please provide a backfield_id" if backfield_id.nil?
  delete "#{@endpoint}/campaigns/#{campaign_id}/backfields/#{backfield_id}"
end

#delete_campaign_beacon(campaign_id, beacon_id) ⇒ Object



145
146
147
148
149
# File 'lib/fosbury/client.rb', line 145

def delete_campaign_beacon campaign_id, beacon_id
  raise "Please provide a campaign_id" if campaign_id.nil?
  raise "Please provide a beacon_id" if beacon_id.nil?
  delete "#{@endpoint}/campaigns/#{campaign_id}/ibeacons/#{beacon_id}"
end

#delete_campaign_location(campaign_id, location_id) ⇒ Object



109
110
111
112
113
# File 'lib/fosbury/client.rb', line 109

def delete_campaign_location campaign_id, location_id
  raise "Please provide a campaign_id" if campaign_id.nil?
  raise "Please provide a location_id" if location_id.nil?
  delete "#{@endpoint}/campaigns/#{campaign_id}/locations/#{location_id}"
end

#delete_pass(pass_id) ⇒ Object



77
78
79
# File 'lib/fosbury/client.rb', line 77

def delete_pass pass_id
  delete "#{@endpoint}passes/#{pass_id}"
end

#delete_program_backfield(program_id, backfield_id) ⇒ Object



237
238
239
240
241
# File 'lib/fosbury/client.rb', line 237

def delete_program_backfield program_id, backfield_id
  raise "Please provide a program_id" if program_id.nil?
  raise "Please provide a backfield_id" if backfield_id.nil?
  delete "#{@endpoint}/programs/#{program_id}/backfields/#{backfield_id}"
end

#delete_program_beacon(program_id, beacon_id) ⇒ Object



256
257
258
259
260
# File 'lib/fosbury/client.rb', line 256

def delete_program_beacon program_id, beacon_id
  raise "Please provide a program_id" if program_id.nil?
  raise "Please provide a beacon_id" if beacon_id.nil?
  delete "#{@endpoint}/programs/#{program_id}/ibeacons/#{beacon_id}"
end

#delete_program_location(program_id, location_id) ⇒ Object



220
221
222
223
224
# File 'lib/fosbury/client.rb', line 220

def delete_program_location program_id, location_id
  raise "Please provide a program_id" if program_id.nil?
  raise "Please provide a location_id" if location_id.nil?
  delete "#{@endpoint}/programs/#{program_id}/locations/#{location_id}"
end

#delete_program_member(program_id, member_id) ⇒ Object



203
204
205
206
207
# File 'lib/fosbury/client.rb', line 203

def delete_program_member program_id, member_id
  raise "Please provide a program_id" if program_id.nil?
  raise "Please provide a member_id" if member_id.nil?
  delete "#{@endpoint}programs/#{program_id}/members/#{member_id}"
end

#delete_template(teplate_id) ⇒ Object



69
70
71
# File 'lib/fosbury/client.rb', line 69

def delete_template teplate_id
  delete "#{@endpoint}tempates/#{template_id}"
end

#distribute_campaign(campaign_id) ⇒ Object



93
94
95
96
# File 'lib/fosbury/client.rb', line 93

def distribute_campaign campaign_id
  raise "Please provide a campaign_id" if campaign_id.nil?
  post "#{@endpoint}campaigns/#{campaign_id}/distribute"
end

#get_campaign(id) ⇒ Object



29
30
31
# File 'lib/fosbury/client.rb', line 29

def get_campaign id
  get "#{@endpoint}campaigns/#{id}"
end

#get_campaign_backfields(campaign_id) ⇒ Object



115
116
117
118
# File 'lib/fosbury/client.rb', line 115

def get_campaign_backfields campaign_id
  raise "Please provide a campaign_id" if campaign_id.nil?
  get "#{@endpoint}/campaigns/#{campaign_id}/backfields"
end

#get_campaign_beacons(campaign_id) ⇒ Object



132
133
134
135
# File 'lib/fosbury/client.rb', line 132

def get_campaign_beacons campaign_id
  raise "Please provide a campaign_id" if campaign_id.nil?
  get "#{@endpoint}/campaigns/#{campaign_id}/ibeacons"
end

#get_campaign_locations(campaign_id) ⇒ Object



98
99
100
101
# File 'lib/fosbury/client.rb', line 98

def get_campaign_locations campaign_id
  raise "Please provide a campaign_id" if campaign_id.nil?
  get "#{@endpoint}/campaigns/#{campaign_id}/locations"
end

#get_campaignsObject



17
18
19
# File 'lib/fosbury/client.rb', line 17

def get_campaigns
  get "#{@endpoint}campaigns"
end

#get_pass(id) ⇒ Object



33
34
35
# File 'lib/fosbury/client.rb', line 33

def get_pass id
  get "#{@endpoint}passes/#{id}"
end

#get_passesObject



21
22
23
# File 'lib/fosbury/client.rb', line 21

def get_passes
  get "#{@endpoint}passes"
end

#get_program(id) ⇒ Object



155
156
157
# File 'lib/fosbury/client.rb', line 155

def get_program id
  get "#{@endpoint}programs/#{id}"
end

#get_program_backfields(program_id) ⇒ Object



226
227
228
229
# File 'lib/fosbury/client.rb', line 226

def get_program_backfields program_id
  raise "Please provide a program_id" if program_id.nil?
  get "#{@endpoint}/programs/#{program_id}/backfields"
end

#get_program_beacons(program_id) ⇒ Object



243
244
245
246
# File 'lib/fosbury/client.rb', line 243

def get_program_beacons program_id
  raise "Please provide a program_id" if program_id.nil?
  get "#{@endpoint}/programs/#{program_id}/ibeacons"
end

#get_program_locations(program_id) ⇒ Object



209
210
211
212
# File 'lib/fosbury/client.rb', line 209

def get_program_locations program_id
  raise "Please provide a program_id" if program_id.nil?
  get "#{@endpoint}/programs/#{program_id}/locations"
end

#get_program_member(program_id, member_id) ⇒ Object



174
175
176
177
178
# File 'lib/fosbury/client.rb', line 174

def get_program_member program_id, member_id
  raise "Please provide a program_id" if program_id.nil?
  raise "Please provide a member_id" if member_id.nil?
  get "#{@endpoint}programs/#{program_id}/members/#{member_id}"
end

#get_program_members(program_id) ⇒ Object



169
170
171
172
# File 'lib/fosbury/client.rb', line 169

def get_program_members program_id
  raise "Please provide a program_id" if program_id.nil?
  get "#{@endpoint}programs/#{program_id}/members"
end

#get_programsObject



151
152
153
# File 'lib/fosbury/client.rb', line 151

def get_programs
  get "#{@endpoint}programs"
end

#get_template(id) ⇒ Object



25
26
27
# File 'lib/fosbury/client.rb', line 25

def get_template id
  get "#{@endpoint}templates/#{id}"
end

#get_templatesObject



13
14
15
# File 'lib/fosbury/client.rb', line 13

def get_templates
  get "#{@endpoint}templates"
end

#push_pass(pass_id, options = {}) ⇒ Object



81
82
83
# File 'lib/fosbury/client.rb', line 81

def push_pass pass_id, options={}
  put "#{@endpoint}passes/#{pass_id}/push", options
end

#push_program(program_id, options = {}) ⇒ Object



164
165
166
167
# File 'lib/fosbury/client.rb', line 164

def push_program program_id, options={}
  raise "Please provide a program_id" if program_id.nil?
  post "#{@endpoint}programs/#{program_id}/push_message", options
end

#redeem_pass(pass_id) ⇒ Object



89
90
91
# File 'lib/fosbury/client.rb', line 89

def redeem_pass pass_id
  post "#{@endpoint}passes/#{pass_id}/redeem"
end

#update_campaign(campaign_id, options = {}) ⇒ Object



60
61
62
63
# File 'lib/fosbury/client.rb', line 60

def update_campaign campaign_id, options={}
  raise "Please provide a campaign_id" if campaign_id.nil?
  put "#{@endpoint}campaigns/#{campaign_id}", options
end

#update_pass(pass_id, options = {}) ⇒ Object



65
66
67
# File 'lib/fosbury/client.rb', line 65

def update_pass pass_id, options={}
  put "#{@endpoint}passes/#{pass_id}", options
end

#update_program(program_id, options = {}) ⇒ Object



159
160
161
162
# File 'lib/fosbury/client.rb', line 159

def update_program program_id, options={}
  raise "Please provide a program_id" if program_id.nil?
  put "#{@endpoint}programs/#{campaign_id}", options
end

#update_program_member(program_id, member_id, customer_number, first_name, last_name, email = nil) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/fosbury/client.rb', line 191

def update_program_member program_id, member_id, customer_number, first_name, last_name, email=nil
  raise "Please provide a program_id" if program_id.nil?
  raise "Please provide a member_id" if member_id.nil?
  raise "Please provide a customer_number" if customer_number.nil?
  raise "Please provide a first_name" if first_name.nil?
  raise "Please provide a last_name" if last_name.nil?

  options = { customer_number: customer_number, first_name: first_name, last_name: last_name, email: email}

  put "#{@endpoint}programs/#{program_id}/members/#{member_id}", options
end

#update_template(template_id, options = {}) ⇒ Object



55
56
57
58
# File 'lib/fosbury/client.rb', line 55

def update_template template_id, options={}
  raise "Please provide a template_id" if template_id.nil?
  put "#{@endpoint}tempates/#{template_id}", options
end