minimul / xero-api

Pure JSON-in, JSON-out Ruby client for Xero API
MIT License
5 stars 2 forks source link

xero-api with qbo_api gem exceptions handling #1

Closed blahutka closed 5 years ago

blahutka commented 5 years ago

Hi Christian, thank you for this gem.

I discovered problem with xero-api gem. when I use it together with qbo_api in the exact order first Xero second QBO

# Gemfile 
gem 'xero-api'
gem 'qbo_api', "~> 1.8.4"

It doesn't handle unauthorized exceptions and raises parsing error

JSON::ParserError at /agendas/1/supplier_automation/download_all
784: unexpected token at 'oauth_problem=token_expired&oauth_problem_advice=The%20access%20token%20has%20expired'

When I switch the loading order it seems ok

# Gemfile 
gem 'qbo_api', "~> 1.8.4"
gem 'xero-api'
Xero::Api::Unauthorized at /agendas/1/supplier_automation/download_all
oauth_problem=token_expired&oauth_problem_advice=The%20access%20token%20has%20expired`
blahutka commented 5 years ago

It tries to load qbo_api exceptions instead of xero-api image

minimul commented 5 years ago

Thanks @blahutka for finding and reporting this. I believe the problem is improper name spacing. See https://github.com/minimul/xero-api/tree/raise-namespace but I didn't try to reproduce. Can you give it a go? Thanks much.

blahutka commented 5 years ago

@minimul Yes, this is working. Thank you

minimul commented 5 years ago

Fixed and released in v 1.0.1