treatwell / rubocop-treatwell

A Ruby style guide by Treatwell
MIT License
2 stars 1 forks source link

treatwell using rails? #3

Open krtschmr opened 10 months ago

krtschmr commented 10 months ago

so, now that i learn that TW is using rails, i wonder, when can i get an API token?

currently i must query the API with session cookies. i think TW can do better. yes, i raised this question to partner@ but they didn't even understand what i was talking about.

while i run my own salon where i use TW, simultaneous i developed my own PoS/accounting for my salon and need some API calls.

it's no fun :(

pls send help!

production code (lol)


 agent = Mechanize.new
  response = agent.post('https://connect.treatwell.nl/api/authentication.json', {
      user: 'xxxx',
      password: 'xxxx',
      persistentLogin: false
    }, { 'Content-Type' => 'application/json' }
  );

  # CN = open
  # CP = checked out

  url = "https://connect.treatwell.nl/api/venue/xxxx/calendar.json?date-from=2023-11-20&date-to=2023-11-20&include=appointments&appointment-status-codes=CN,CR"
  json = JSON.parse(agent.get(url).body);

  a = json.fetch("appointments").collect do |appointment|
    OpenStruct.new(
      time: appointment.dig("startTime"),
      name: appointment.dig("consumerName"),
      email: appointment.dig("consumerEmail"),
      phone: appointment.dig("consumerPhone")
    )
  end.sort_by(&:time)
arizz96 commented 10 months ago

Hi @krtschmr, thank you for asking! As far as I know there are no publicly supported APIs, so I think your implementation might be unstable as there's no agreement to keep supporting that type of authentication going forward.

Treatwell has products already available with POS hardware integration, so I'd like to encourage you contacting our sales representative that can surely help you and your salon finding a suitable solution.