mailjet/mailjet-gem

Can't get template detail info

Closed this issue · 2 comments

Detail content returns nil.

irb(main):061:0> Mailjet::Template.find(TEMPLATE_ID)
=> #<Mailjet::Template:0x007f834987f838 @attributes=>
irb(main):062:0> Mailjet::Template_detailcontent.find(TEMPLATE_ID)
=> nil

Verified with CURL:

$ curl -s -X GET \
> --user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
> https://api.mailjet.com/v3/REST/template/TEMPLATE_ID/detailcontent
=> {"Count":1,"Data":[{"MJMLContent":{"tagName":"mjml","attributes":{"version":"3.3.5"},"children":[{"tagName":"mj-body",.......

I think the problem is how the get URL is composed. If I use a hash as an argument, I get a bad URI error that shows the ID is being appended to the end of the get url by the rubygem.

 Mailjet::Template_detailcontent.find(id: "foobar")
=> URI::InvalidURIError: bad URI(is not URI?): https://api.mailjet.com/v3/REST/template/{:id=>"foobar"}/detailcontent/{:id=>"foobar"}

So the gem is hitting /template/TEMPLATE_ID/detailcontent/TEMPLATE_ID when it should be hitting /template/TEMPLATE_ID/detailcontent?

Having a little bit of trouble trying to work through the gem and figure out how to fix this, so I'll hope that the mailjet team is willing to add a fix.

FWIW, the workaround I'm using now with HTTParty:

auth = {:username => ENV.fetch('MAILJET_KEY'), :password => ENV.fetch('MAILJET_SECRET')}
template = HTTParty.get("https://api.mailjet.com/v3/REST/template/#{template_id}/detailcontent", :basic_auth => auth)
html_part = template.parsed_response['Data'][0]["Html-part"]

Is this issue still actual? I cannot reproduce it