2016-09-19 62 views
1

我正在使用DocuSign REST API的docusign_rest gem,以下是我的DocuSign配置。Docusign与rails 4的集成

# config/initializers/docusign_rest.rb 

require 'docusign_rest' 
DocusignRest.configure do |config| 
    config.username  = '[email protected]' 
    config.password  = 'MyPassword' 
    config.integrator_key = 'My-key' 
    config.account_id  = 'account_id' 
    config.endpoint  = 'https://www.docusign.net/restapi' 
    config.api_version = 'v1' 
end 

当我尝试连接并获取account_id时,我得到nil作为响应。

client = DocusignRest::Client.new 
puts client.get_account_id   # Returns nil. 

我使用rails-4.1.4ruby-2.2.2

我错过了什么?请建议。

+1

你试过'config.api_version ='v2''吗? – DiegoSalazar

回答

1

不知道你是否明白这一点或不完全。这是另一个解决方案,使用httparty并不困难。如果你想创建例如模板的文档,你的要求看起来可能是这样:

baseUrl = "https://demo.docusign.net/restapi/v2/accounts/acct_number/envelopes" 
    @lease = Lease.find(lease.id) 
    @unit = @lease.unit 
    @application = @lease.application 
    @manager = @lease.property_manager 

    @application.applicants.each do |renter| 
    req = HTTParty.post(baseUrl, 
     body: { 
      "emailSubject": "DocuSign API call - Request Signature - Boom", 
      "templateId": "id of your template", 
      "templateRoles": [{ 
       "name": "#{renter.background.legal_name}", 
       "email": "#{renter.email}", 
       "recipientId": "1", 
       "roleName": "Lessee", 
       "tabs": { 
        "texttabs": [{ 
           "tablabel": "Rent", 
           "value": "#{@lease.rent}" 
           },{ 
           "tablabel": "Address", 
           "value": "987 apple lane" 
         }] 
        } 
       },{ 
       "email": "#{@manager.email}", 
       "name": "#{@manager.name}", 
       "roleName": "Lessor", 
       "tabs": { 
        "texttabs": [{ 
           "tablabel": "Any", 
           "value": "#{@lease.labels}" 
           },{ 
           "tablabel": "Address", 
           "value": "987 hoser lane" 
        }] 
       } 
      }], 
      "status": "sent" 
     }.to_json, 
     headers: { 
      "Content-Type" => "application/json", 
      'Accept' => 'application/json', 
      'X-DocuSign-Authentication' => '{ 
      "Username" : "place your", 
      "Password" : "credentials", 
      "IntegratorKey" : "here" 
      }' 
     }, :debug_output => $stdout) 

最终线调试输出是让你调试API请求,其可以在去除任何时候。

1

这是docusign_rest 0.1.1中的一个bug;该方法总是返回nil。该错误已被fixed和最新的宝石版本包括该修复程序。