Following the documentation to create a custom plugin for fastlane.
Got an error while trying to use it :
Error in lane my_lane: undefined method `configure' for Fastlane::Mailjet:Module
It seems fastlane is trying to call a configure method somewhere.
However since there is no mention of it in the documentation i have absolutly no clue of what i should do.
Plugin available here : https://github.com/tirrorex/fastlane-plugin-mailjet
Call the action in my lane with
mailjet(
api_key: "key",
secret_key: "key",
sender: {
:email => "mail#mail.com",
:name => "Name"
},
recipients: options[:recipients],
subject: "subject",
textPart: "
Text.
",
templateLanguage: true,
templateErrorReporting: "mymail#mail.com",
templateErrorDeliver: "deliver",
templateId: id,
vars: {
"success":success,
"build_link": build_link,
},
attachments: attachments
)
The issue seems to be that in my plugin/action i use the mailjet gem.
When i try to call my mailjet action in my lane, fastlane instead is calling the mailjet gem which requires the configure method hence the error.
So it is a naming issue.
Any thoughts ?
Related
I'm using RSwag (2.7) to generate API documentation based on tests on Rails 6.1. The problem is that using the same method specified in the official documentation I get an RSpec error.
I need to add a pretty complex request body and the documentation https://github.com/rswag/rswag states you can use
request_body_example value: { some_field: 'Foo' }, name: 'request_example_1', summary: 'A request example'
to specify a body request example for your request.
So I have this test:
post 'Creates holdings in bulk' do
tags 'Holdings'
produces 'application/json'
consumes 'application/json'
request_body_example name: 'some name' summary: 'Request example description', value: { 'some hash' }
it_behaves_like '200_response', 'Holdings'
end
But it raises:
NoMethodError:
undefined method `request_body_example' for RSpec::ExampleGroups::Holdings::Bulk::HoldingsBulk::Post:Class
Did you mean? require_or_load
Is there something I'm doing wrong? It seems like it's the same as the documentation.
I can create a new stripe connect account with
require 'stripe'
Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
Stripe::Account.create({
type: 'express',
country: 'US',
email: 'jenny.rosen#example.com',
capabilities: {
card_payments: {requested: true},
transfers: {requested: true},
},
})
I understand I can provide that account with a test address using a 'token' called address_full_match. But I have no idea what that 'token' is nor how to use it in ruby code, that is, I do not know what ruby code to write to use this 'token'
I tried the obvious to generate/access a token:
Stripe::address_full_match
NoMethodError: undefined method `address_full_match' for Stripe:Module
from (pry):10:in `__pry__'
How can I use this 'token' in ruby code (specifically, in Stripe::Account.create()) ?
Further attempts
Attempt 1
If we search the documentation for any instances of enabled": true it returns zero results, but if we search for instances of enabled": false we get 16 results. So the documentation doesn't provide a single example creating an account with either charges_enabled: true, nor with payouts_enabled: true, which is surprising since that's predominantly what developers want to do - create account functional accounts (not dysfunctional ones)
Attempt 2
I tried placing address_full_match in the 'Address line 1' field of the web UI. But it still results in payments_enabled: false
You will get it from StripeCheckout JS client
you have to include js script from stripe
<script src="https://checkout.stripe.com/checkout.js"></script>
Again create a script and In the js script you have to write like
StripeCheckout.configure({
key: "<%= Rails.configuration.stripe[:publishable_key] %>",
locale: "auto",
name: "XYZ",
description: "XYZ Description",
email: "<%= current_user.email %>",
billingAddress: true,
zipCode: true,
token: function(token) {
console.log("Stripe Token : " + token.id)
}
});
I'm building a Rails API using the gem 'graphql' and want to access this GraphQL API using a Gatsby.js front-end. I've attempted to use gatsby-source-apiserver plugin and gatsby-source-graphql, but neither of them seem to work. (The API works fine when I do queries using the GraphiQL app on my local machine.)
Is there a better Gatsby.js source plugin what will work well with a Rails API using the gem 'graphql', which provides a single endpoint, http://localhost:3000/graphql? And if so, how should I configure that plugin in gatsby-config.js, etc? (BTW, I'm using a Postgres database which I intend to deploy to Heroku -- I'd thought about pursuing hasura, but I'm not sure if that's the best option.)
In the Rails API in routes.rb, I've set up post "/graphql", to: "graphql#execute" to route to GraphqlController. Here is the execute method in the Controller...
def execute
variables = ensure_hash(params[:variables])
query = params[:query]
operation_name = params[:operationName]
context = {
# Query context goes here, for example:
# current_user: current_user,
}
result = GraphqlRailsSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
render json: result
rescue => e
raise e unless Rails.env.development?
handle_error_in_development e
end
When I attempt to render the json: result, result is: #<GraphQL::Query::Result #query=... #to_h={"errors"=>[{"message"=>"No query string was present"}]}> for either of the front-end set-ups I cite below....
In my Gatsby.js front-end, when I use gatsby-source-apiserver, in gatsby-config.js, I have...
{
resolve: 'gatsby-source-apiserver',
options: {
typePrefix: 'internal__',
url: `http://localhost:3000/graphql`,
method: 'post',
headers: {
'Content-Type': 'application/json'
},
data: {
},
name: `posts`,
entityLevel: `data.posts`,
payloadKey: `body`,
}
},
...and I get his error in my console when I run gatsby develop...
TypeError: Cannot read property 'data' of undefined
And, when I use gatsby-source-graphql, I have this in gatsby-config.js...
{
resolve: "gatsby-source-graphql",
options: {
// This type will contain remote schema Query type
typeName: "Authors",
// This is field under which it's accessible
fieldName: "authors",
// Url to query from
url: "http://localhost:3000/graphql",
},
},
...and I get his error in my console when I run gatsby develop...
Error: Cannot find module 'gatsby/graphql'
As you can see, I'm confused about how to connect the schemas between the front-end and the back-end here. Any help on this would be much appreciated!
I am building a rails 5 app that is deployed on heroku.
I want to use AWS congnito to achieve single sign on, but there are not enough example to implement it.
I am using devise for authentication. Now my goal is to put my all users on AWS cognito and authenticate them from my rails App.
This is the only resource i found on AWS congnito with rails, I am looking for some example application or a link to tools or ruby API document to achieve this.
Please Help.
Update On basis Of Bala Answer
require 'aws-sdk'
ENV['AWS_ACCESS_KEY_ID'] = 'XXXXXXXXXXXXXXXXX'
ENV['AWS_SECRET_ACCESS_KEY'] = 'XXXX+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
region_name = 'us-east-1'
endpoint = 'cognito-idp.us-east-1.amazonaws.com'
client = Aws::CognitoIdentityProvider::Client.new(
region: region_name
)
resp = client.admin_create_user({
user_pool_id: "us-east-1_iD7xNHj0x", # required
username: "Test", # required
user_attributes: [
{
name: "email", # required
value: "sachin.singh#example.com",
},
],
validation_data: [
{
name: "Email", # required
value: "AttributeValueType",
},
],
temporary_password: "PasswordType",
force_alias_creation: false,
message_action: "RESEND", # accepts RESEND, SUPPRESS
desired_delivery_mediums: ["EMAIL"], # accepts SMS, EMAIL
})
Error stack trace
home/sachin/.rvm/gems/ruby-2.1.5#global/gems/aws-sdk-core-2.6.38/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call': User does not exist. (Aws::CognitoIdentityProvider::Errors::UserNotFoundException)
from /home/sachin/.rvm/gems/ruby-2.1.5#global/gems/aws-sdk-core-2.6.38/lib/aws-sdk-core/plugins/idempotency_token.rb:18:in `call'
from /home/sachin/.rvm/gems/ruby-2.1.5#global/gems/aws-sdk-core-2.6.38/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from /home/sachin/.rvm/gems/ruby-2.1.5#global/gems/aws-sdk-core-2.6.38/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from /home/sachin/.rvm/gems/ruby-2.1.5#global/gems/aws-sdk-core-2.6.38/lib/seahorse/client/request.rb:70:in `send_request'
from /home/sachin/.rvm/gems/ruby-2.1.5#global/gems/aws-sdk-core-2.6.38/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
from aws_cognito.rb:20:in `<main>'
Update 2
resp = client.admin_initiate_auth({
user_pool_id: "us-east-1_uKM", # required
client_id: "3g766413826eul9kre28qne4f", # required
auth_flow: "ADMIN_NO_SRP_AUTH",
auth_parameters: {
"EMAIL" => "kapil.sachdev#metacube.com",
"PASSWORD" => "Ibms#1234"
}
})
First of all, you need to create a user pool for your application
Use this link to create user pool through AWS console
You can find the ruby methods for sign_up, sign_in, change password and many other functions at http://docs.aws.amazon.com/sdkforruby/api/Aws/CognitoIdentityProvider/Client.html
EDIT
Now, you can sign up the user using sign_up
sign_in a user using
admin_initiate_auth
if you need mobile number confirmation, email confirmation you need to configure the user pool that you are creating.
You can find the corresponding methods for confirming the mobile numbers using http://docs.aws.amazon.com/sdkforruby/api/Aws/CognitoIdentityProvider/Client.html#confirm_sign_up-instance_method
I am using Ruby 1.9.3 and getting the following error on the following line while trying to use the SendGrid API.
ERROR [on this line below "mailer.mail(mail_defaults)"]:
NoMethodError (undefined method `to_h' for #<Hash:0x00000005da0958>):
CODE:
assuming some users
recipients = []
recipient = SendGrid::Recipient.new('jn#geo.com')
recipient.add_substitution('name', 'Billy Bob')
recipient.add_substitution('number', 1234)
recipient.add_substitution('time', '10:30pm')
recipients << recipient
# then initialize a template
template = SendGrid::Template.new('blahblah7bef2-d25b00')
# create the client
# see client above
# set some defaults
mail_defaults = {
:from => 'no-reply#geo.com',
:html => '<h1>I like email tests</h1>',
:text => 'I like email tests',
:subject =>'Test Email is great',
}
mailer = SendGrid::TemplateMailer.new(client, template, recipients)
# then mail the whole thing at once
mailer.mail(mail_defaults)
I thought it might be my mail_defaults array so I tried this (see below) and received the same error on the same line.
mail_defaults = {
from: 'no-reply#geo.com',
html: '<h1>I like email tests</h1>',
text: 'I like email tests',
subject: 'Test Email is great',
}
Do I have an error in my code or is their an error in SendGrids mailer.mail method?
This problem is with mail.mailer. This uses the to_h method internally, which was implemented in Ruby 2.1. Effectively, the sendgrid sdk requires ruby 2.1 now. I had the same issue with Ruby 1.9.3 and solved it by upgrading to 2.1.
This is what I used to upgrade to Ruby 2.1 on CentOS 6 (not my gist):
https://gist.github.com/mustafaturan/8290150
Hope this helps.