Add keywords to handle additional fields in API response
Thank you for your work on this useful gem!
I was testing out the API and was getting some errors where there were more keys being passed to the constructor of B2::Bucket and B2::File than expected. Maybe the response has gained a few new fields recently:
2.2.3 :006 > Backblaze::B2::Bucket.buckets
ArgumentError: unknown keywords: bucket_info, lifecycle_rules, revision
from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:12:in `initialize'
from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:151:in `new'
from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:151:in `block in buckets'
from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:149:in `map'
from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:149:in `buckets'
I also added an alias to B2::Bucket#bucket_name because I was getting this error in B2::File#download_url
:015 > b
=> #<Backblaze::B2::Bucket:0x00000001ea99e8 ...>
2.2.3 :016 > f
=> #<Backblaze::B2::File:0x00000001d9a480 ...>
2.2.3 :017 > f.download_url bucket: b
NoMethodError: undefined method `name' for #<Backblaze::B2::Bucket:0x00000001ea99e8>
from /home/atsui/work/b2/lib/backblaze/b2/file.rb:116:in `download_url'
While I was at it, I added a first_file keyword for B2::Bucket#file_names so you can search a bucket by filename.
By the way, I am working on a paperclip gem using the backblaze gem as a base, and I was stuck on how to provide support for creating B2::Files from Paperclip's file adapter. Let me know if you'd be interested, it would be great to have your feedback.
Thank you very much for this! I have really been meaning to get this gem to a stable and more compliant state, but over the last few months, life has been catching up with me. I'll absolutely look over this in the morning when I have time. Hopefully, it works with the changes I'd been testing in my general-refactoring branch. I would absolutely be interested in helping and also welcome any feedback you have on the direction in which this gem should be taken.
@R167 Glad to hear your reply!
I'm trying to see how much work to fold in the commits from the general-refactoring branch. There's not too many conflicts, but I'm getting this error:
NameError: uninitialized constant Backblaze::B2::UrlManager::Singleton
from /home/atsui/backblaze/lib/backblaze/b2/url_manager.rb:6:in `<class:UrlManager>'
Maybe there was a file that wasn't committed?
If you'd like, we can try to get the error squared away and I can do some tests, then I'll update my master branch so we can see all the changes at a glance here.