简体   繁体   English

Docusign与Rails集成4

[英]Docusign integration with rails 4

I am using the docusign_rest gem for DocuSign REST API, and following are my DocuSign configuration. 我正在为docuSign REST API使用docusign_rest gem,以下是我的DocuSign配置。

# config/initializers/docusign_rest.rb

require 'docusign_rest'
DocusignRest.configure do |config|
  config.username       = 'myemail@email.com'
  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

When I try to connect and get account_id, I get nil as a response. 当我尝试连接并获取account_id时,我得到nil作为响应。

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

I am using rails-4.1.4 and ruby-2.2.2 我正在使用rails-4.1.4ruby-2.2.2

What did I miss? 我错过了什么? Please suggest. 请提出建议。

Not sure if you figured this out or not quite yet. 不知道您是否想到了这一点。 Here is another solution that wasn't too difficult using httparty. 这是另一个使用httparty不太困难的解决方案。 If you're trying to create a document for a template for example, your request might look like so: 例如,如果您尝试为模板创建文档,则您的请求可能如下所示:

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 )

debug output on the final line is to allow you to debug the api request, it can be removed at any time. 最后一行的debug输出是为了允许您调试api请求,可以随时将其删除。

This was a bug in docusign_rest 0.1.1; 这是docusign_rest 0.1.1中的错误; that method always returned nil . 该方法总是返回nil That bug has been fixed and the latest gem version includes that fix. 该错误已得到修复 ,最新的gem版本包括该修复程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM