Sha256: be83b4a0de7b2d0ec0cee1ad79712bda5528ea2802344a18a97e507758ce227d

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'supersaas-api-client'

puts '# SuperSaaS Forms Example'

unless Supersaas::Client.instance.account_name && Supersaas::Client.instance.api_key
  puts 'ERROR! Missing account credentials. Rerun the script with your credentials, e.g.'
  puts '    SSS_API_ACCOUNT_NAME=<myaccountname> SSS_API_KEY=<xxxxxxxxxxxxxxxxxxxxxx> ./examples/appointments.rb'
  return
end

puts "## Account:  #{Supersaas::Client.instance.account_name}"
puts "## API Key: #{'*' * Supersaas::Client.instance.api_key.size}"

Supersaas::Client.instance.verbose = true

puts 'You will need to create a form, and also attach the form to a booking, see documentation on how to do that'
puts 'The below example will take a form in random, and if it is not attached to something then 404 error will be raised'

puts 'listing forms...'
puts '#### Supersaas::Client.instance.forms.forms'

template_forms = Supersaas::Client.instance.forms.forms

if template_forms.size.positive?
  template_form_id = template_forms.sample.id

  puts 'listing forms from account'
  puts '#### Supersaas::Client.instance.forms.list'
  form_id = Supersaas::Client.instance.forms.list(template_form_id).sample.id
end

puts 'getting form...'
puts "#### Supersaas::Client.instance.forms.get(#{form_id})"
Supersaas::Client.instance.forms.get(form_id)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
supersaas-api-client-2.0.5 examples/forms.rb
supersaas-api-client-2.0.4 examples/forms.rb
supersaas-api-client-2.0.3 examples/forms.rb
supersaas-api-client-2.0.2 examples/forms.rb