constantcontact / ruby-sdk

Constant Contact Ruby SDK for v2 API
Other
17 stars 47 forks source link

Dependency issue #63

Closed pauldruziak closed 6 years ago

pauldruziak commented 7 years ago

To upgrade to Ruby 2.4 we need update rest-client, but we can't because of constantcontact. Any suggestion?

Bundler could not find compatible versions for gem "rest-client":
  In Gemfile:
    rest-client (~> 2.0.0)

    constantcontact (~> 1.3.1) was resolved to 1.3.2, which depends on
      rest-client (>= 1.6.7, ~> 1.6)
andreaslillebo commented 7 years ago

We have a similar issue.

Updating this gem to support rest-client 2.x would solve this issue: https://github.com/rest-client/rest-client#upgrading-to-rest-client-20-from-1x

scratchoo commented 6 years ago

I have a similar but not same issue :

Bundler could not find compatible versions for gem "mime-types":
  In snapshot (Gemfile.lock):
    mime-types (= 3.1)

  In Gemfile:
    constantcontact (~> 3.0) was resolved to 3.0.0, which depends on
      mime-types (>= 2.4.1, ~> 2.4)

    rails (~> 5.0.4) was resolved to 5.0.4, which depends on
      actionmailer (= 5.0.4) was resolved to 5.0.4, which depends on
        mail (>= 2.5.4, ~> 2.5) was resolved to 2.6.6, which depends on
          mime-types (< 4, >= 1.16)

    rest-client (>= 2.0.2, ~> 2.0) was resolved to 2.0.2, which depends on
      mime-types (< 4.0, >= 1.16)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

I also have gem 'rest-client', '~> 2.0', '>= 2.0.2' in my gemfile

any solution for this please ?

csciuto commented 6 years ago

@medBouzid - is your Gemfile.lock out of date? However, as @pauldruziak and @andreaslillebo have pointed out, the rest-client version becomes a problem.

As you can see from our Travis runs, we're currently supporting back to Ruby 1.9 and rest-client 2.0 requires Ruby 2.x. 1.9 is so old that I'd happily drop support for it but I need to ask around about that.

For the time being, I'd recommend forking, updating the rest-client dependency, removing the mime-types dependency, and possibly updating json and going from there.

Are you using Rails here? We may want to continue supporting Rails 4.2 a little longer as it is still receiving security patch updates.

scratchoo commented 6 years ago

@csciuto I am using Rails 5.0.4 and ruby 2.4.0p0 there is nothing old in my part ! when I run gem list and check for mime-types I see :

mime-types (3.1)
mime-types-data (3.2016.0521)

I have many other gems that are depending on rest-client and there is no problem with them at all, I am not sure why this happens only with this gem!

csciuto commented 6 years ago

I'm surprised to see it pulling in 3.1.

The gemspec for the current version of the ctct gem is this:

  s.add_runtime_dependency("rest-client", '~> 1.6', '>= 1.6.7')
  s.add_runtime_dependency("json", '~> 1.8', '>= 1.8.1')
  s.add_runtime_dependency('mime-types', '~> 2.4', '>= 2.4.1')
  s.add_development_dependency("rspec", '~> 2.14')

That should max out mime-type at 2.99, which is what my gemfile.lock has when I do bundle update.

Note though that you will have a rest-client version incompatibility no matter what because the Constant Contact gem requires 1.x and you're using 2.x.

scratchoo commented 6 years ago

@csciuto I downgraded my rest-client to 1.x and that may solve the problem for rest client, I also tried to do bundle update mime-types and got another error for json :

Bundler could not find compatible versions for gem "json": In snapshot (Gemfile.lock): json (= 2.1.0)

constantcontact (~> 3.0) was resolved to 3.0.0, which depends on json (>= 1.8.1, ~> 1.8)

If I understand well my Rails version 5.0.4 has "mime-types" and "json" versions that are (higher) not supported yet by this gem, the actual version of Rails is 5.1.3 so I don't see any reason to not upgrade those version in your part

csciuto commented 6 years ago

Hi, let me know if this build solves your issues: https://rubygems.org/gems/constantcontact/versions/4.0.0

scratchoo commented 6 years ago

@csciuto Thanks that solve the dependencies issue, one question though, when I add a contact through the API the "middle_name" field doesn't get saved, I pass a json like this :

{ 'email_addresses':[{'email_address':'fromlib@gmail.com'}], 'lists':[{'id':'1912237938'}], 'first_name':'firstname', 'middle_name':'middlename'}

I've tried this using the add_contact method and also directly using a post request to the api endpoint but I get the same result (I mean : the "middle_name" is missing from the contact info )

I used a third party app that send the middle_name and it works! I don't know why it does not work with my code, also I noticed that the third party app can send also the "name", but I couldn't find any "name" field in the documentation, there is only "first_name" and "last_name" and "middle_name" (this last doesn't get saved as mentioned), so I am just asking by curiosity if we can send the "name" as well ?

csciuto commented 6 years ago

@medBouzid - Middle name is a deprecated field with inconsistent support across Constant Contact. The third party app you are using that supports it is most likely built on our V1 XML API (https://community.constantcontact.com/t5/Documentation/Contacts-Collection-and-Resource/ba-p/25989). The field is not visible through the UI today. The 'name' field is similarly obsolete, and was documented as being a read-only concatenation of first and last name..

scratchoo commented 6 years ago

@csciuto oh thank you for the explanation, is there any other obsolete fields so I can avoid using them ?

Here is a list of the fields I am using currently :

fields = {

            "first_name": "First Name",
            "last_name": "Last Name",
            "email_address": "Email Address",
            "job_title": "Job title",
            "home_phone": "Home Phone",
            "work_phone": "Work Phone",
            "fax": "Fax",
            "city": "City",
            "country_code": "country",
            "line1": "Address line 1",
            "line2": "Address line 2",
            "line3": "Address line 3",
            "address_type": "Address Type",
            "postal_code": "Postal Code",
            "state": "State",
            "cell_phone": "Cell Phone",
            "company_name": "Company Name"

        }

Also you may need to delete "middle_name" from here : https://github.com/constantcontact/ruby-sdk/blob/master/lib/constantcontact/util/config.rb#L102

csciuto commented 6 years ago

Those fields should be fine. They match what's here in https://developer.constantcontact.com/docs/contacts-api/contacts-collection.html . Note that middle_name is not present, nor is name.

I did notice the ruby sdk does show middle name as a field. I understand that it's confusing. It interestingly works in my accounts still, but it also works via direct API calls. As I stated though, it's deprecated. Logged https://github.com/constantcontact/ruby-sdk/issues/68

Closing this issue (dependencies) as it appears to be resolved.