Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route example in README broken? #37

Open
fredrik opened this issue Mar 29, 2015 · 3 comments
Open

Route example in README broken? #37

fredrik opened this issue Mar 29, 2015 · 3 comments

Comments

@fredrik
Copy link

fredrik commented Mar 29, 2015

Copy-pasting the example in the README yields a Mailgun::Error:

irb(main):013:0> @mailgun.routes.create "Description for the new route", 1,
irb(main):014:0*        [:match_recipient, "apowers@mi5.co.uk"],
irb(main):015:0*        [[:forward, "http://my-site.com/incoming-mail-route"],
irb(main):016:1*           [:stop]]
Mailgun::Error: 'action' parameter is missing
@ajsharp
Copy link
Contributor

ajsharp commented May 12, 2015

I get this as well. Either an error in the code or in the README.

@ajsharp
Copy link
Contributor

ajsharp commented May 12, 2015

Looking at the relevant part of the code, there is a bug where the data['actions'] part of the params hash is built:

    def create(description, priority, filter, actions)
      data = ::Multimap.new

      data['priority']    = priority
      data['description'] = description
      data['expression']  = build_filter(filter)

      actions = build_actions(actions)

      actions.each do |action|
        data['action'] = action
      end

      # TODO: Raise an error or return false if unable to create route
      Mailgun.submit(:post, route_url, data)["route"]["id"]
    end

build_actions returns an array of strings, and then each one is iterated through, overwriting the data['actions'] param, only assigning the final action. So yea, the bug is in the code, as far as I can tell.

cc @HashNuke

@ajsharp
Copy link
Contributor

ajsharp commented May 12, 2015

My fault, it seems this functionality is provided by the embedded Multimap library. Still, this functionality throws an error for me. Maybe mailgun changed their API signature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants